I have a pretty easy question. (using C)
In a sentence such as
In this document, there are 345 words and 6 figures
How can I scan 345 and 6 while ignoring all that is in between ?
I tried fscanf(FILE *pointer,"%d %d",&words,&figs);
But it only gets the first value …
What am I doing wrong ?
EDIT
Im sorry I forgot to mention, the statement is always fixed …
In this document, there are # words and # figures
This is because functions of the
scanf()family are meant to read from strings written with aprintf()like function with the same format. Since is the case here, no need to resort to string parsing and conversions to integers:Of course, the format has to be exactly the same, at least before the values that are read, so it’s safer to keep it in one place, following the Once and Only Once principle, and necessary to test the
fscanf()return code.