It is printing correctly but I have confusion that whenever I write just msg, it gives me Your ?@ and whenever I write msg[option-1], it gives me full message of Your name is bilal. I am not understanding the cause of [option-1]. Why it is used and what is it's function?
#include <stdio.h>
#define MAX_LEN 256
int main(){
FILE * fp = fopen("file.txt","r");
int option;
char word[MAX_LEN];
static const char * const msg[] = {
"Name",
"Date of Birth",
"ID Card Number",
"Phone Number",
"Address",
"Account",
"Fixing Year",
"Amount" };
for (option = 1; option <= sizeof(msg)/sizeof(char *); ++option)
printf("%d. Your %s:\n", option, msg[option-1]);
fclose(fp);
return 0;
}