I am trying to learn how to display the pointer value in decimal and hexadecimal. below you can see me create a value and try to use a pointer to print out the value and the values location.
Please make the code work correctly so that it prints out the values in decimal and hexadecimal
double val= 1;
printf("The value of val : %f\n",val);
double *ptr;
ptr= &val;
printf("dereference *ptr= %f\n", *ptr);
//Display the location of val with and without pointer use in decimal and hex
//decimal
printf("location of val in decimal with ptr is: %p\n",(void *) ptr);
printf("location of val in decimal without a pointer is: %p\n",(void *) &val );
//hexadecimal THIS IS NOT WORKING
printf("location of val in hex with ptr is: %#x\n", (void *) ptr);
printf("location of val in hex without a pointer is: %#x\n", (void *) &val );