Explanation of Article on Scanf ()

The C++ reference article has this passage in it:

Non-whitespace character, except percentage signs (%): Any character that is not either a whitespace character (blank, newline or tab) or part of a format specifier (which begin with a % character) causes the function to read the next character from stdin, compare it to this non-whitespace character and if it matches, it is discarded and the function continues with the next character of format.

How can a a non-format character match the data type of an input character? If it did match, it would then have to be a format character. Also, if it did match, why would you then discard the character? Maybe a definition of the term "match" would be helpful to clarify the issue.
I don't use C functions myself, but it appears that with a file like this:

value: 5


and a prog like this:
1
2
3
int i;
scanf(file, "value: %d", &i);
fprintf(stdio,"%d", i);


the output would be


5


Note that I didn't test this, just try it yourself.
Last edited on
Topic archived. No new replies allowed.