printf format for unsigned __int64 on Windows
Solution 1
Using Google to search for “Visual Studio printf unsigned __int64” produces this page as the first result, which says you can use the prefix I64
, so the format specifier would be %I64u
.
Solution 2
%llu
is the standard way to print unsigned long long
, it's not just for Linux, it's actually in C99. So the problem is actually to use a C99-compatible compiler, i.e, not Visual Studio.
C99 7.19.6 Formatted input/output functions
ll(ell-ell) Specifies that a following d, i, o, u, x, or X conversion specifier applies to a long long int or unsigned long long int argument; or that a following n conversion specifier applies to a pointer to along long int argument.
Solution 3
Printf has different format specifiers for unsigned long long
depending on the compiler, I have seen %llu
and %Lu
. In general I would advice you to use std::cout
and similar instead.
Virus721
Updated on January 04, 2020Comments
-
Virus721 over 4 years
I need to print a
ULONGLONG
value (unsigned __int64
). What format should i use inprintf
? I found%llu
in another question but they say it is for linux only.Thanks for your help.