+ 1
What is the suitable format specifier of pointer in c language??
5 Réponses
+ 17
To output an unsigned value, use %u.
%u - Unsigned decimal integers
+ 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;
}
+ 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.
+ 1
What is %u format specifier??