I have a variable of type size_t, and I want to print it using printf(). What format specifier do I use to print it portably?
size_t
printf()
In 32-bit ma
For C89, use %lu and cast the value to unsigned long:
%lu
unsigned long
size_t foo; ... printf("foo = %lu\n", (unsigned long) foo);
For C99 and later, use %zu:
%zu
size_t foo; ... printf("foo = %zu\n", foo);