Format Specifiers in C
Here, I am gonna tabulate the format specifiers used in C language.
Code | Format |
---|---|
%c | Character |
%d | Signed decimal integers |
%i | Signed decimal integers |
%e | Scientific notation (lowercase e) |
%E | Scientific notation (uppercase E) |
%f | Decimal floating point |
%g | Uses %e or %f, whichever shorter (in length) |
%G | Uses %E or %f, whichever shorter (in length) |
%o | Unsigned octal |
%s | String of characters |
%u | Unsigned decimal integers |
%x | Unsigned hexadecimal (lowercase letters) |
%X | Unsigned hexadecimal (uppercase letters) |
%p | Displays a pointer |
%n |
The associated argument must be a pointer to an integer. This specifier causes the number of characters written so far to be put into that integer |
%% | Prints a % sign. |
%ld | Long int |
%lf | Double floating point number. |
%Lf | Long Double floating point number. |