can fscanf skip reading data conditionally?



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!!

.



Relevant Pages

  • Re: can fscanf skip reading data conditionally?
    ... John wrote: ... joe 100 ...
    (comp.lang.c)
  • Re: can fscanf skip reading data conditionally?
    ... joe 100 ... char name; ...
    (comp.lang.c)
  • Re: Longest day of my life
    ... >> I won't attempt to speak for Joe or Os. ... Surely you're not suggesting that I don't have a firm handle on ... I'm doing my best to keep up, but in the end the only advice I can ... Perhaps if you just went about being the quiet nerdy bloke and forgot ...
    (uk.sport.football)
  • Re: I need serious help!
    ... I know Joe doesn't (he says that, and he responds very well to helpful ... Guys, limit your posts to technical advice, like code samples, stories ... about your own forays into game programming as kids, ... tip) or flames, in which case - just drop it. ...
    (comp.lang.ruby)
  • Re: Problems at work!
    ... Joe doesn't want to work in the same ... dismissed the employment tribunals are closed to him as they ... will not consider a dismissal if discrimination is alleged. ... This is too imporant an issue to rely on the mixed advice that you are ...
    (uk.legal)