- New line, insert a new line after printed text.
\n- tab, indents text to the right.
\t
printf("\tindented text\n");Output
indented text- escape, allows printing of double quotes etc.
\"
printf("\"text inside double quote\".\n");Output
"text inside double quotes."Watch out for this, compile error occur.
printf("\");To print a backslash , you need to escape it first.
\\
printf("Escape symbol is \"\\\"\n");Output
Escape symbol is "\"%[flags] [width] [.precision] specifier
- int type
%d- float or double types
%f- double type
%lf- char type
%c- strings
%sField width helps to print tables.
Specify the field width for a given specifier.
Field width set to 10.
printf("|||%10d|||\n", 5);Output
||| 5|||- right align, no flag (default)
- Left align flag is: -
printf("|||%-10d|||\n", 5);Output
|||5 |||Define the precision of float or doubles.
For two floating points of precision. i.e modify 5.4567 to 5.46, use .2 as precision.
printf("|||%10.2f|||\n", 5.456700);Output
||| 5.46|||printf("ACCEL_CONFIG bitfields = 0x%02X\n", accelConfigReg8);Output
ACCEL_CONFIG bitfields = 0xB0