When printing out a pointer’s value (the memory address it points to) using a
printf function and a
%p format specifier, we need to cast that pointer to type
void* first. Simply trying to print out the pointer value through
printf causes undefined behavior. Example:
int main(void)
{
int x = 123;
int *p = &x;
printf("The pointer value is: %p\n", p); // undefined behavior
}
Possible Output:The pointer value is: 0x7ffc57d762ec
This example causes undefined ...