Yes/No question about pointers

If my assignment gives me this:

1
2
3
4
5
6
7
8
9
double var1, *p1;
cout<< "enter a number to put into var1:";
cin>>var1;
p1 = &var1;
cout<< "var1 holds the value: "<< var1<< " which should be the same as "<< *p1 << endl;
cout<< " p1 points to the memory address "<< p1 << "which holds the value of "<< *p1<< endl;
	
*p1 = 23;
cout<< "var1 is now changed to: "<< var1 << endl;


And tells me to do this:
Add another double pointer to the code, assign the value of p1 to the new pointer. Make your program print the value of the new pointer and the value that it points to.


Do I do the EXACT same thing as what was given but with two, or is there some trick?
You probably need to use new to intialise another pointer to a double. When you're done, remember to release the memory you allocated with new.
You do exactly what the statement says to do.

It says to write three lines of code:

1. Add another double pointer (ie, declare a pointer to double variable)
2. Assign the value of p1 to it
3. Print the value of the pointer and what it points to (note your line 6 already does that for p1).
Topic archived. No new replies allowed.