How can I print the memory address of a pointer using printf (or any other STDOUT functions?). I see in Linux its %p but not in unix, help?
thanks
How can I print the memory address of a pointer using printf (or any other STDOUT functions?). I see in Linux its %p but not in unix, help?
thanks
"UNIX" is an extremely vague description, and about as useful for describing your system as telling a mechanic that your car is blue in color. If you don't actually know what your system is, uname and uname -a should help.
It should be %p in most UNIX too. %p doesn't always print the exact same thing everywhere, though!
ah yes, sorry, its FreeBSD 7.3
What happens when you compile and run this code:
#include <stdio.h>
int main(void)
{
printf("pointer: %p\n", NULL);
}
prints out..
pointer: 0x0
however, if I try to print out a pointer address in the kernel code and compile, it returns that %p is looking for a void.
Kernel code is not application code. You don't have printf() in the kernel. The concept of 'standard output' doesn't even exist inside the kernel.
You might try kprintf(), which is similar. I think it ends up printing to the system log.
If it's giving you warnings about the wrong kind of pointer, you might try casting the pointer into a (void *).