printf

Cross platform format string

#include <stdint.h>    // for uint64_t
#include <inttypes.h>  // for PRIu64
 
size_t my_variable;
printf("%" PRIu64 "\n", (uint64_t)my_variable);

https://www.cplusplus.com/reference/cinttypes/ https://stackoverflow.com/questions/174612/cross-platform-format-string-for-variables-of-type-size-t/174674#174674

Float padding

The field width includes the decimal point and the fractional portion (and the sign, if it's negative).

Padding negative numbers

Flags:

  • - Left-justify the given field width (see Width below). Right justification is the default.
  • + Forces a “+” sign to precede a number. Has no effect on negative numbers.
  • (space) One blank space is inserted before a positive number, while negative numbers are unaffected. This is useful for making positive and negative numbers vertically align in a visual stacked list.