C Format Specifiers





Integer Format Specifiers:

%d : Used to print or scan integers (decimal format).

%o : Used to print or scan integers in octal (base 8) format.

%x or %X : Used to print or scan integers in hexadecimal (base 16) format.

Floating-Point Format Specifiers:

%f : Used to print or scan floating-point numbers (decimal notation).

%e or %E : Used to print or scan floating-point numbers in scientific notation.

%g or %G : Used to print or scan floating-point numbers in either %f or %e format, whichever is shorter.

Character Format Specifiers:

%c : Used to print or scan characters.

%s : Used to print or scan strings (sequences of characters).

Pointer Format Specifiers:

%p : Used to print or scan pointers (memory addresses).

Width and Precision Specifiers:

%Nd : Specifies a minimum field width N for the output, where N is an integer.

%.Nf : Specifies the number of digits after the decimal point for floating-point output, where N is an integer.

\\n : Newline character.

\\t : Tab character.

\\\" : Double-quote character.

\\' : Single-quote character.

\\\\ : Backslash character.



Here's a compilation of common escape sequences:


\n: Newline (Line Feed)
\r: Carriage Return
\t: Horizontal Tab
\v: Vertical Tab
\b: Backspace
\f: Form Feed
\': Single Quote
\": Double Quote
\\: Backslash
\0: Null Character
\xhh: Hexadecimal Escape (where hh represents hexadecimal digits)
\uhhhh: Unicode Escape for 16-bit characters (where hhhh represents four hexadecimal digits)
\Uhhhhhhhh: Unicode Escape for 32-bit characters (eight hexadecimal digits)
\a: Alert (generally produces a system-specific alert sound)
\e: Escape (may not be supported in all languages)
\nnn: Octal Escape (where nnn represents three octal digits)