A pointer is a variable that stores a memory address in it
Memory locations are typically addressed using Hexadecimal
Pointer declaration syntax
PointedType* PointerVariableName
Example:
int* result
As is the case with most other variables when you don’t initialize a pointer it is given a random value which in this case would be a random address in memory that could be pointing to something important so you would typically initialize a pointer to NULL
int* result = NULL
In order to get the memory address for a specific variable you would need to use the reference operator (&)
In order to get the data stored in a memory address you would need to use the dereference operator (*)
You can use the dereference operator to manipulate the data at the end of the pointer
int age = 24;
int* ptr = &age;
// ptr is an integer pointer that points to the location in memory that stores 'age'
*ptr = 30;
//age would now be 30 because you accessed it through the pointer