All that is needed is that the format specifiers and types are consistent, and you can always do this to make it true. long is at least 32 bits, so %lu along with (unsigned long)k always correct:
uint32_t k; printf("%lu\n", (unsigned long)k);
size_t more complicated, so %zu was added in C99. If you cannot use this, then treat it the same as k ( long is the largest type in C89, size_t unlikely to be larger).
size_t sz; printf("%zu\n", sz); printf("%lu\n", (unsigned long)sz);
If you do not specify format specifiers for the type you are passing, then printf will do the equivalent of reading too much or too little memory from the array. As long as you use explicit tricks to match types, they are portable.
u0b34a0f6ae Nov 08 2018-11-11T00: 00Z
source share