- 1
How it is giving this output
int score = 5; int *scorePtr; scorePtr = &score; cout << scorePtr << endl; //Outputs "0x29fee8"
2 Antworten
0
& gives the location in memory of the variable, whereas * give the value of the memory location. what you want to do is this
int score = 5;
int *scorePtr = &score;
cout << *scorePtr << endl;
0
c++ basic tuto
score is a variable with 5 as value
&score is the value's address and his type is a pointer.
cout displays value's address of the pointer.