How to print space in uint64_t (C)
Question
When I try this:
#include <stdio.h>
#include <inttypes.h>
int main (int argc, char **argv)
{
uint64_t key = 0xf0000000ffffffff;
printf ("key=%" PRIx64, key, "\t\n %" PRIx64, "\n", key);
}
It prints key=f0000000ffffffff
; all whitespaces are removed. How can I print them? I am using gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
.
Solution
The format string you provide to printf
is only
"key=%" PRIx64
All the rest are arguments for the format string, ans since the format string only contain one conversion specifier the first argument is printed and the rest are discarded.
I think you want e.g.
printf("key=%" PRIx64 "\t\n %" PRIx64 "\n", key, key);
Note the lack of commas in the format string.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow