CC Pointers
Memory addresses.
C Pointers
A pointer is a variable that stores the memory address of another variable as its value.
A pointer variable points to a data type (like int) of the same type, and is created with the * operator.
The address of the variable you are working with is assigned to the pointer:
int myAge = 43; // An int variable
int* ptr = &myAge; // A pointer variable, with the name ptr, that stores the address of myAge
Dereference
You can also use the pointer to get the value of the variable, by using the * operator (the dereference operator).
Examples
Create Pointer
c examplePrinting address and value.
#include <stdio.h>
int main() {
int myAge = 43;
int* ptr = &myAge;
printf("%d\n", myAge); // Outputs the value of myAge (43)
printf("%p\n", &myAge); // Outputs the memory address of myAge
printf("%p\n", ptr); // Outputs the memory address of myAge with the pointer
return 0;
}