QP School

Full Version: Understanding pointers and memory addresses in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pointers are variables that store memory addresses.

int num = 10;
int *ptr; // Declare a pointer
ptr = # // Assign the address of num to the pointer

printf("Value of num: %d\n", num); // Output: 10
printf("Address of num: %p\n", &num); // Output: Address in hexadecimal format
printf("Value of ptr: %p\n", ptr); // Output: Address of num