Monday, May 31, 2021

 

Different Format Specifiers available in C


Format specifiers define the type of data to be printed on standard output. You need to use format specifiers whether you're printing formatted output with printf() or accepting input with scanf().

Below are some of the format specifiers that are available in ANSI C

SPECIFIER

USED FOR

%c

a single character

%s

a string

%hi

short (signed)

%hu

short (unsigned)

%Lf

long double

%n

prints nothing

%d

a decimal integer (assumes base 10)

%i

a decimal integer (detects the base automatically)

%o

an octal (base 8) integer

%x

a hexadecimal (base 16) integer

%p

an address (or pointer)

%f

a floating point number for floats

%u

int unsigned decimal

%e

a floating point number in scientific notation

%E

a floating point number in scientific notation

%%

the % symbol










No comments:

Post a Comment