MS Visual Studio didn't support %zu
printf specifier before VS2013
. Starting from VS2013 (e.g. _MSC_VER
>= 1800
) %zu
is available.
As an alternative, for previous versions of Visual Studio if you are printing small values (like number of elements from std containers) you can simply cast to an int
and use %d
:
printf("count: %d
", (int)str.size()); // less digital ink spent
// or:
printf("count: %u
", (unsigned)str.size());
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…