I want to print out the value of a size_t
variable using printf
in C++ using Microsoft Visual Studio 2010 (I want to use printf
instead of <<
in this specific piece of code, so please no answers telling me I should use <<
instead).
According to the post
the correct platform-independent way is to use %zu
, but this does not seem to work in Visual Studio. The Visual Studio documentation at
http://msdn.microsoft.com/en-us/library/vstudio/tcxf1dw6.aspx
tells me that I must use %Iu
(using uppercase i
, not lowercase l
).
Is Microsoft not following the standards here? Or has the standard been changed since C99? Or is the standard different between C and C++ (which would seem very strange to me)?
The I, I32, and I64 length modifier prefixes are Microsoft extensions and are not ANSI-compatible
, which seems to answer your question about MS following standards. – Aspasia