I just got started learning about pointers and was executing some code:
#include <stdio.h> int main(void){ int num = 12; // initialize num to 12 int *pnum = NULL; // initialize the pointer pnum = # // stores the address of num in pnum printf("the address of the number is %p\n", &num); // display the address of the number printf("the address of the pointer is %p\n", &pnum); // display the address of the pointer printf("the value of the pointer is %p\n", pnum); // display the value of the pointer printf("the value the pointer is pointing to is %d\n", *pnum); // display the value the pointer is pointing to return 0; } In this code above, It prints out 0xffffcbec for the address of the number and value of the pointer, and 0xffffcbe0 for the address of the pointer. I want to know the reason. I feel like this is related to some incorrect inputs of data types.
I use VScode btw.
I want to know the reason.The reason for what? Its quite unclear what you're asking.pnumis because the address ofpnumis 0xffffcbe0.