QP School
Understanding pointers and memory addresses in C - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: C 18 Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=32)
+--- Thread: Understanding pointers and memory addresses in C (/showthread.php?tid=5091)



Understanding pointers and memory addresses in C - Qomplainerz - 07-25-2023

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