Loading…
Rewriting printf: a function you call without thinking, resting on a C mechanism almost nobody uses directly.
printf accepts any number of arguments of any type, decided at runtime by reading a format string. Re-coding that forces you to understand a language mechanism most developers never use directly: variadic functions. The delivered version goes beyond the subject and adds colour handling.
A printf reimplementation handling %d %i %u %c %s %b %o %x %X %p %ld %lu %n %%, a few flags (%#o, %#x, %#X, '0', '+', '-', space) and the written-character counter; the bonus folder adds a variant of the library with ANSI-colourised output.
READING SOURCE…