I need to print a ULONGLONG
value (unsigned __int64
). What format should i use in printf
? I found %llu
in another question but they say it is for linux only.
Thanks for your help.
We should use “%zu” to print the variables of size_t length. We can use “%d” also to print size_t variables, it will not show any error. The correct way to print size_t variables is use of “%zu”. In “%zu” format, z is a length modifier and u stand for unsigned type.
for uint64_t type: #include <inttypes. h> uint64_t t; printf("%" PRIu64 "\n", t); you can also use PRIx64 to print in hexadecimal.
To print an unsigned int number, use the %u notation. To print a long value, use the %ld format specifier. You can use the l prefix for x and o, too. So you would use %lx to print a long integer in hexadecimal format and %lo to print in octal format.
In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.
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
.
%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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With