Quick Reference List: Format Specifier, Escape Sequence
Hi,
This post will provide a quick reference list used in various places.
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.
Thanks
Prateek
This post will provide a quick reference list used in various places.
Format Specifier List
| Format Specifier | Description | Supported Data Types |
|---|---|---|
| %c | Character | char unsigned char |
| %d | Signed Integer | short unsigned short int long |
| %e or %E | Scientific notation of float values | float double |
| %f | Floating point | float |
| %g or %G | Similar as %e or %E | float double |
| %hi | Signed Integer(Short) | short |
| %hu | Unsigned Integer(Short) | unsigned short |
| %i | Signed Integer | short unsigned short int long |
| %l or %ld or %li | Signed Integer | long |
| %lf | Floating point | double |
| %Lf | Floating point | long double |
| %lu | Unsigned integer | unsigned int unsigned long |
| %lli, %lld | Signed Integer | long long |
| %llu | Unsigned Integer | unsigned long long |
| %o | Octal representation of Integer. | short unsigned short int unsigned int long |
| %p | Address of pointer to void void * | void * |
| %s | String | char * |
| %u | Unsigned Integer | unsigned int unsigned long |
| %x or %X | Hexadecimal representation of Unsigned Integer | short unsigned short int unsigned int long |
| %n | Prints 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 Sequence | Meaning |
|---|---|
| \a | Alarm or Beep |
| \b | Backspace |
| \f | Form Feed |
| \n | New Line |
| \r | Carriage Return |
| \t | Tab (Horizontal) |
| \v | Vertical Tab |
| \\ | Backslash |
| \' | Single Quote |
| \" | Double Quote |
| \? | Question Mark |
| \nnn | octal number |
| \xhh | hexadecimal number |
| \0 | Null |
Thanks
Prateek
Comments
Post a Comment