FT_PRINTF

Mandatory part:

  • Manage the following conversions: s, p, d, i, o, u, x, X & c
  • Manage %%
  • Manage the flags #, 0, -, + & space
  • Manage the minimum field-width
  • Manage the precision
  • Manage the flags hh, h, l, ll, & L.

Flags:

\#0-+ and space
- Left-justify within the given field width; Right justification is the default (see width sub-specifier).
+ Forces to preceed the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign.
(space) If no sign is going to be written, a blank space is inserted before the value.
# Used with o, x or X specifiers the value is preceeded with 0, 0x or 0X respectively for values different than zero. Used with a, A, e, E, f, F, g or G it forces the written output to contain a decimal point even if no more digits follow. By default, if no digits follow, no decimal point is written.
0 Left-pads the number with zeroes (0) instead of spaces when padding is specified (see width sub-specifier).

Length sub-specifier:

length d i u o x X f F e E g G a A c s p
none int unsigned int double int char* void*
hh signed char unsigned char
h short int unsigned short int
l long int unsigned long int wint_t wchar_t*
ll long long int unsigned long long int
j intmax_t uintmax_t
z size_t size_t
L long double

Bonuses:

  • '*' flag

  • '%k' - prints current date

  • '%t' - printf current time

Links:

1. https://stackoverflow.com/questions/1449805/how-to-format-a-number-from-1123456789-to-1-123-456-789-in-c
  1. http://www.cplusplus.com/reference/cstdio/printf/

  2. https://linux.die.net/man/3/stdarg