+ 1

What is the suitable format specifier of pointer in c language??

18th Jun 2019, 5:08 PM
Gaurav Rawat
Gaurav Rawat - avatar
5 ответов
+ 17
To output an unsigned value, use %u. %u - Unsigned decimal integers
19th Jun 2019, 4:47 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 16
If you wish to display an address, use %p. This format specifier causes printf( ) to display a machine address in a format compatible with the type of addressing used by the computer. The next program displays the address of sample: #include <stdio.h> int sample; int main() { printf("%p", &sample); return 0; }
18th Jun 2019, 6:44 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 4
I'd just like to add that the (void *) cast is necessary since the standard doesn't guarantee that all pointers have the same size or alignment. int x; printf("%p\n", (void *)&x); The void pointer cast is the correct way to print addresses as - swim - has shown.
18th Jun 2019, 7:17 PM
Cluck'n'Coder
Cluck'n'Coder - avatar
+ 1
What is %u format specifier??
19th Jun 2019, 2:54 AM
Gaurav Rawat
Gaurav Rawat - avatar