Format Specifiers in C

In this article you will get list of format specifiers in C.

Format specifier is used to specify the data type while reading or writing. For example if you want to print value of an integer type variable then you have to use %d in printf() function. Take below example.

 

As you can see that I have used %d while reading and printing integer value.

C language has various format specifiers that I have listed below.

 

List of Format Specifiers in C

Data Type Format Specifier
char %c
signed char %c (or %hhi for numerical output)
unsigned char %c (or %hhu for numerical output)
short
short int
signed short
signed short int
%hi
unsigned short

unsigned short int

%hu
int

signed

signed int

%i or %d
unsigned

unsigned int

%u
long

long int

signed long

signed long int

%li
unsigned long

unsigned long int

%lu
long long

long long int

signed long long

signed long long int

%lli
unsigned long long

unsigned long long int

%llu
float %f (promoted automatically to double for printf())
double %f (%F)

(%lf (%lF) for scanf())

%g  %G

%e  %E (for scientific notation)

long double %Lf  %LF

%Lg  %LG

%Le  %LE

 

Comment below if you found anything incorrect or missing in above list of format specifiers in C.

Source: https://en.wikipedia.org/wiki/C_data_types

1 thought on “Format Specifiers in C”

Leave a Comment

Your email address will not be published. Required fields are marked *