J
John
I need to read data from the file like the following with name and
score, but some line may only has name without score:
joe 100
amy 80
may
Here's my code, but it couldn't read the line with "may" because there
is no score. Anyone knows what is the workaround to this problem?
char name[20];
int score;
while (fscanf(ifp, "%s %d", name, &score) == 2)
{
printf("%s %d\n", name, score);
}
please advice. thanks!!
score, but some line may only has name without score:
joe 100
amy 80
may
Here's my code, but it couldn't read the line with "may" because there
is no score. Anyone knows what is the workaround to this problem?
char name[20];
int score;
while (fscanf(ifp, "%s %d", name, &score) == 2)
{
printf("%s %d\n", name, score);
}
please advice. thanks!!