Portable code for printing size
This question already has an answer here:
C99 and C11 require a z
modifier:
sprintf(buf, "%zu", i);
If MS Visual Studio has to be accommodated too, life is probably harder (because it doesn't adhere to either the C99 or C11 standard). According to MSDN, you need to use I
instead of z
.
上一篇: 用于64位十六进制的便携式printf格式说明符?
下一篇: 便携式打印尺寸代码