home -> linux

printf() Conversion Characters

commonly used conversions are in bold
Conversion CharacterArgument TypeConverted Type
Non-numeric
%cint x(unsigned char) x
%lcwint_t xwchar_t a[2] = {x}
%nint * ptr--
%hnshort * ptr--
%pvoid * ptr(void *) ptr
%schar * ptr (char x[])ptr[0]...
%lswchar_t * ptr (wchar_t x[])ptr[0]...
%lnlong * ptr--
%%nonethe '%' character
Base 8 conversion (octal)
%oint x(unsigned int) x
%hoint x(unsigned short) x
%lolong x(unsigned long) x
Base 10 conversion (decimal)
%dint x(int) x
%hdint x(short) x
%ldlong x(long) x
%edouble x(double) x
%Lelong double x(long double) x
%Edouble x(double) x
%fdouble x(double) x
%Lflong double x(long double) x
%gdouble x(double) x
%Lglong double x(long double) x
%Gdouble x(double) x
%LGlong double x(long double) x
%iint x(int) x
%hiint x(short) x
%lilong x(long) x
%hiint x(short) x
%lilong x(long) x
%hiint x(short) x
%uint x(unsigned int) x
%huint x(unsigned short) x
%lulong x(unsigned long) x
Base 16 conversion (hexadecimal)
%xint x(int) x
%hxint x(unsigned short) x
%lxlong x(long) x
%Xint x(unsigned int) x
%hXint x(unsigned short) x
%lXlong x(unsigned long) x