The formatting
placeholders in scanf are more or less the same as that in
printf, its reverse function. As in printf, the POSIX extension is defined. An example of a format string is :"%7d%s %c%lf" The above format string scans the first seven characters as a decimal integer, then reads the remaining as a string until a space,
newline, or tab is found, then consumes whitespace until the first non-whitespace character is found, then consumes that character, and finally scans the remaining characters as a
double. Therefore, a robust program must check whether the scanf call succeeded and take appropriate action. If the input was not in the correct format, the erroneous data will still be on the input stream and must discarded before new input can be read. An alternative method, which avoids this, is to use
fgets and then examine the string read in. The last step can be done by
sscanf, for example. In the case of the many float type characters , many implementations choose to collapse most into the same parser. Microsoft MSVCRT does it with , while
glibc does so with all four. ISO C99 includes the
inttypes.h header file that includes a number of macros for use in platform-independent coding. These must be outside double-quotes, e.g. Example macros include: == Vulnerabilities ==