how to extract characters of a language?

What does this mean: "Whitespace characters in the format string are matched by zero or more whitespace characters in the input stream and discarded when using the function scanf in the C language"?

  • I do not understand the above sentence. Note: I'm only talking about numeric entry via scanf. Besides the question of what, generally, does the above sentence mean, what happens if there are no whitespace characters in the format string to be matched with, say, 5 whitespace characters in the input string. This is from a textbook, and the above statement is just about 99% of the explanation of this topic. So I don't have much to go on.

  • Answer:

    The format string is the first parameter to the scanf function (also called the format specifier).  The scanf function scans the input stream (stdin) matching it against the format specifier passed as the first parameter. The C(99) specification states that under the "C" locale, the following characters comprise the whitespace set: { ' ', '\f', '\n', '\r', '\t', '\v' } (i.e. what isspace matches). Any encounter of a character from that set will consume any number (0 or more) of whitespace characters from the input stream, and be discarded (that is, you cannot capture them into a variable).  The exception to that is the case where %s or %c in which case the space is considered to be either part of a string or a character and read into a variable of the appropriate type. If there are no whitespace characters in the format specifier, then no whitespace characters will be matched.  Note that the C99 standard requires that the numeric specifiers consume preceeding whitespace during conversions as they are considered padding for the numeric value.

Saleem Abdulrasool at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.