Clean code to printf size_t in C++ (or: Nearest equivalent of C99's %z in C++)

前端 未结 9 2584
醉梦人生
醉梦人生 2020-12-07 14:20

I have some C++ code that prints a size_t:

size_t a;
printf(\"%lu\", a);

I\'d like this to compile without warnings on both 32

9条回答
  •  暖寄归人
    2020-12-07 14:52

    The printf format specifier %zu will work fine on C++ systems; there is no need to make it more complicated.

提交回复
热议问题