I'm teaching pointers to myself through my book and I'm stuck on one of the practice problems. Here it is:
//What is the output of the following C++ code? int x; int y; int *p = &x; int *q = &y; *p = 35; *q = 98; *p = *q; cout << x << " " << y << endl; cout << *p << " " << *q << endl;
I know the answer is 98 98 98 98 but I don't understand how the variables x and y can get 98. Even the first assignment of *p = &x, what does that even mean? Doesn't that mean the memory address of x is assigned to pointer variable p? If someone could run me through this code I would very appreciate it...my head is starting to hurt.