Format specifiers

This table shows the format specifiers used by scanf and printf. The "Format specifier" is the sequence passed as the formatting string argument; "Characters matched" gives the format of the sequence sought or printed, with a hyperlink to the section on literals which applies to that format; "Argument type" gives the type of expression expected by printf and of pointer expected by scanf.
Format specifierCharacters matchedArgument type
%cany single characterchar
%d, %iintegerinteger type
%ooctal integerunsigned
%x, %Xhex integerunsigned
%e, %E, %f, %g, %G floating point numberfloating type
%paddress formatvoid *
%sany sequence of non-whitespace characterschar

Exercises on this section.

Next - user defined types.

Back to Input and Output.

Back to Contents page.