int printf(const char format_str[], ...) int fprintf(FILE *fp, const char format_str[], ...) int sprintf(char output_str[], const char format_str[], ...)
The format string can contain 0 or more format specifications mixed with ordinary characters to be output.
Format specifications are replaced by a converted value.
For each format specification, the parameter list should contain a value to be converted and inserted in place of the format spec.
Some format specifications
Format Specifier | Meaning |
---|---|
%d | Convert an integer value (to decimal using digits 0 - 9) |
%x | Convert an integer value (to hex using 0 - 9 and A - F) |
%s | "convert" a string value (really no conversion needed) |
Between the percent sign and the conversion letter, you can have
- an integer specifying the number of output character positions
to use (sort of like setw for c++ strings)
If the value needs fewer character positions, the value is right justified.
However, if the integer is negative, the number of character positions used is the absolute value and the value is left justified.