Special Hot Alien ?! ;-)

printf format size_t variable

20 Jul 2016

Use the z modifier(C99 addition):

size_t x = ...;
ssize_t y = ...;
printf("%zu\n", x);  // prints as unsigned decimal
printf("%zx\n", x);  // prints as hex
printf("%zd\n", y);  // prints as signed decimal

Looks like it varies depending on what compiler you’re using (blech):

Tweet
comments powered by Disqus