I am trying to read some commands which should be passed to my program from a file. The commands are on different lines, so I guess this means that they are separated by \n
character. This is my command reading section:
FILE *fop;
char command[50];
fopen("mbr.op", "r");
while(!feof(fop))
{
fscanf(fop,"%s[^\n]", command);
printf("%s\n", command);
}
fclose(fop);
This prints some words that are in the file, but not all, and not in the expected order. How could I change this code to achieve the desired result?