[Solved] C printf cross-platform format without warnings [duplicate]

[ad_1] For size_t, assuming you have a sufficiently modern C library, use %zu. If you can’t use the z modifier (some older libraries unfortunately don’t support it), cast to a wide-enough known type when printing, and then use a width specifier appropriate to that type: size_t sz = sizeof(whatever); … printf(“%lu”, (unsigned long)sz); This works … Read more