Portable code for printing size

This question already has an answer here:

  • How can one print a size_t variable portably using the printf family? 12 answers

  • 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 .

    链接地址: http://www.djcxy.com/p/72220.html

    上一篇: 用于64位十六进制的便携式printf格式说明符?

    下一篇: 便携式打印尺寸代码