What’s the correct way to use printf to print a size_t?

Try using the %zu format string

size_t val = get_the_value();
printf("%zu",val);

The z portion is a length specifier which says the argument will be size_t in length.

Source – http://en.wikipedia.org/wiki/Printf#printf_format_placeholders

Leave a Comment