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

前端 未结 9 2574
醉梦人生
醉梦人生 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 15:03

    On windows and the Visual Studio implementation of printf

     %Iu
    

    works for me. see msdn

提交回复
热议问题