printf
Basic Usage
Format Specifiers
%c
Treat the arguments as a single character.
%d
Treat the input as a decimal (integer) number (base 10).
%e
Treats the input as an exponential floating-point number.
%f
Treat the input as a floating-point number.
%i
Treat the input as an integer number (base 10).
%o
Treats the input as an octal number (base 8).
%s
Treat the input as a string of characters.
%u
Treat the input as an unsigned decimal (integer) number.
%x
Treats the input as a hexadecimal number (base 16).
%%
Print a percent sign.
%Wd
Print the W
integer X
digits wide.
%(format)T
Outputs a date-time string resulting from using format as a format string for strftime
. The corresponding argument can be the number of seconds since Epoch (January 1, 1970, 00:00), -1
(the current time), or -2
(shell startup time). Not specifying an argument uses the current time as the default value.
\%
Print a percent sign.
\n
Prints a newline
character.
\t
Print a tab
character.
When multiple specifiers are used, they are replaced by a corresponding argument.
Last updated
Was this helpful?