List of Format Specifiers in C
List of Format Specifiers in C
The below table contains the most commonly used format specifiers in C
Format Specifier Description
%i Unsigned integer
%lf Double
%o Octal representation
%p Pointer
%s String
%u Unsigned int
%x or %X Hexadecimal representation
Format Specifier Description
%n Prints nothing
%% Prints % character
The data types in C can be classified as follows:
Types Description
Primitive data types are the most basic data types that are
Primitive Data
used for representing simple values such as integers, float,
Types
characters, etc.
The data types that are derived from the primitive or built-in
Derived Types
datatypes are referred to as Derived Data Types.
User Defined
The user-defined data types are defined by the user himself.
Data Types
Size Format
Data Type (bytes) Range Specifier
unsigned
2 0 to 65,535 %hu
short int
-2,147,483,648 to
int 4 %d
2,147,483,647
-2,147,483,648 to
long int 4 %ld
2,147,483,647
unsigned long
4 0 to 4,294,967,295 %lu
int
unsigned long 0 to
8 %llu
long int 18,446,744,073,709,551,615
unsigned
1 0 to 255 %c
char
Size Format
Data Type (bytes) Range Specifier
float 4 %f
1.2E-38 to 3.4E+38
double 8 %lf
1.7E-308 to 1.7E+308
Operator
Precedence Description Associativity
Parentheses
()
(function call)
Array Subscript
[]
(Square Brackets)
Structure Pointer
->
Operator
Postfix increment,
++ , —
decrement
Prefix increment,
++ / —
decrement
Logical NOT,
!,~
Bitwise complement
Dereference
*
Operator
Determine size in
sizeof
bytes
Operator
Precedence Description Associativity
Multiplication,
3 *,/,% Left-to-Right
division, modulus
Relational is equal
7 == , != Left-to-Right
to, is not equal to
Bitwise exclusive
9 ^ Left-to-Right
OR
12 || Logical OR Left-to-Right
14 = Assignment Right-to-Left
+= , -= Addition, subtraction
Operator
Precedence Description Associativity
assignment
Multiplication,
*= , /=
division assignment
Modulus, bitwise
%= , &=
AND assignment
Bitwise exclusive,
^= , |= inclusive OR
assignment
comma (expression
15 , Left-to-Right
separator)