Use the z
modifier:
size_t x = ...;
ssize_t y = ...;
printf("%zu\n", x); // prints as unsigned decimal
printf("%zx\n", x); // prints as hex
printf("%zd\n", y); // prints as signed decimal
More Related Contents:
- in c printf() returns what [closed]
- What does %d mean? Why d and not another letter? [closed]
- char c[]=”Albus”; printf(“%c”, c); [closed]
- C: unable to print from file
- printf anomaly after “fork()”
- How do you allow spaces to be entered using scanf?
- C/C++ printf() before scanf() issue
- Set variable text column width in printf
- sprintf() with automatic memory allocation?
- Printing UTF-8 strings with printf – wide vs. multibyte string literals
- What does “%.*s” mean in printf?
- How to printf a memory address in C
- string format for intptr_t and uintptr_t
- C: Which character should be used for ptrdiff_t in printf?
- printf specify integer format string for float
- Difference between fprintf, printf and sprintf?
- How to repeat a char using printf?
- How to format strings using printf() to get equal length in the output
- C Programming: Forward variable argument list
- Left-pad printf with spaces
- write() to stdout and printf output not interleaved?
- fork() in c using printf [duplicate]
- Variable sized padding in printf
- printf of a size_t variable with lld, ld and d type identifiers
- Why does “printf” not produce any output?
- colorful text using printf in C
- C printf using %d and %f
- How do I align a number like this in C?
- Turbo C++: Why does printf print expected values, when no variables are passed to it?
- printf() formatting for hexadecimal