I am new to C++ and I'm trying to understand pointers. I have researched and understood the general idea, what they are and how to use them etc.
My question is, if I can declare a pointer to store a memory location of another variable can I then use that information to change the data that is stored at that particular memeory location?
int x = 6; //Declare variable and store 6 in it
int* ptr = &x; //Declare pointer pointing at memory area x occupied
*ptr = 1; //Write 1 to the memory area ptr pointing at
std::cout << x; //output bvalue of x