Conversion Specification Modifiers for printf() - C Language Basics

C examples for Language Basics:printf

Introduction

Modifier Meaning
flag you can use - , + , space, # , and 0 as flags.
digit(s) The minimum field width. Example: "%4d".
.digit(s)Precision.
h Used with an integer specifier to indicate a short int or unsigned short int value. Examples: "%hu" , "%hx" , and "%6.4hd".
hh Used with an integer specifier to indicate a signed char or unsigned char value. Examples: "%hhu" , "%hhx" , and "%6.4hhd".
jUsed with an integer specifier to indicate an intmax_t or uintmax_t defined in stdint.h. Examples: "%jd" and "%8jX".
l Used with an integer specifier to indicate a long int or unsigned long int . Examples: "%ld" and "%8lu".
ll Used with an integer specifier to indicate a long long int or unsigned long long int . (C99). Examples: "%lld" and "%8llu".
L Used with a floating-point specifier to indicate a long double value. Examples: "%Lf" and "%10.4Le".
t Used with an integer specifier to indicate a ptrdiff_t value. Examples: "%td" and "%12ti".
z Used with an integer specifier to indicate a size_t value. Examples: "%zd" and "%12zx".

Related Tutorials