Tutorial by Examples

To print the value of a pointer to an object (as opposed to a function pointer) use the p conversion specifier. It is defined to print void-pointers only, so to print out the value of a non void-pointer it needs to be explicitly converted ("casted*") to void*. #include <stdlib.h> /*...
Subtracting the values of two pointers to an object results in a signed integer *1. So it would be printed using at least the d conversion specifier. To make sure there is a type being wide enough to hold such a "pointer-difference", since C99 <stddef.h> defines the type ptrdiff_t. ...
Conversion SpecifierType of ArgumentDescriptioni, dintprints decimaluunsigned intprints decimalounsigned intprints octalxunsigned intprints hexadecimal, lower-caseXunsigned intprints hexadecimal, upper-casefdoubleprints float with a default precision of 6, if no precision is given (lower-case used f...
Accessed through including <stdio.h>, the function printf() is the primary tool used for printing text to the console in C. printf("Hello world!"); // Hello world! Normal, unformatted character arrays can be printed by themselves by placing them directly in between the parenthes...
The C99 and C11 standards specify the following length modifiers for printf(); their meanings are: ModifierModifiesApplies tohhd, i, o, u, x, or Xchar, signed char or unsigned charhd, i, o, u, x, or Xshort int or unsigned short intld, i, o, u, x, or Xlong int or unsigned long intla, A, e, E, f, F, ...
The C standard (C11, and C99 too) defines the following flags for printf(): FlagConversionsMeaning-allThe result of the conversion shall be left-justified within the field. The conversion is right-justified if this flag is not specified.+signed numericThe result of a signed conversion shall always ...

Page 1 of 1