Looking at the man page of printf (man 3 printf), in the length modifier section, it is written:
z A following integer conversion corresponds to a
size_torssize_targument. (Linux libc5 hasZwith this meaning. Don't use it.)
Therefore,
size_t x = sizeof (int);
printf ("%zd\n", x);
But, it is said that the length modifier z exists only in C99 and newer systems.
Old systems don't recognize it. So, the old fashioned way to the the stuff is to perform explicit casting:
printf ("%lu\n", (unsigned long int) x);
Anyway, it's better to move to the new stuff.
Archive: All about C Programming