Quick Reference List: Format Specifier, Escape Sequence

Hi,
This post will provide a quick reference list used in various places.

Format Specifier List


Format SpecifierDescriptionSupported Data Types
%cCharacterchar
unsigned char
%dSigned Integershort
unsigned short
int
long
%e or %EScientific notation of float valuesfloat
double
%fFloating pointfloat
%g or %GSimilar as %e or %Efloat
double
%hiSigned Integer(Short)short
%huUnsigned Integer(Short)unsigned short
%iSigned Integershort
unsigned short
int
long
%l or %ld or %liSigned Integerlong
%lfFloating pointdouble
%LfFloating pointlong double
%luUnsigned integerunsigned int
unsigned long
%lli, %lldSigned Integerlong long
%lluUnsigned Integerunsigned long long
%oOctal representation of Integer.short
unsigned short
int
unsigned int
long
%pAddress of pointer to void void *void *
%sStringchar *
%uUnsigned Integerunsigned int
unsigned long
%x or %XHexadecimal representation of Unsigned Integershort
unsigned short
int
unsigned int
long
%nPrints nothing
%%Prints % character

Note: Most frequently used format specifiers are highlighted for quick reference.



Escape Sequence in C

In C, escape sequences are sequence of characters which have pre defined meanings. For example while printing on console if you wish to shift cursor to next line the escape sequence used is "\n".

Likewise double quotes ("") and backslash (\) have special meaning in C. If you wish to print double quotes in your output, you have to write it like (\"\").

For quick reference list of escape sequences is given below.

List of Escape Sequences in C

Escape SequenceMeaning
\aAlarm or Beep
\bBackspace
\fForm Feed
\nNew Line
\rCarriage Return
\tTab (Horizontal)
\vVertical Tab
\\Backslash
\'Single Quote
\"Double Quote
\?Question Mark
\nnnoctal number
\xhhhexadecimal number
\0Null




Thanks

Prateek

Comments