- 1

How it is giving this output

int score = 5; int *scorePtr; scorePtr = &score; cout << scorePtr << endl; //Outputs "0x29fee8"

11th Dec 2017, 6:40 AM
utkarsh
2 ответов
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;
11th Dec 2017, 6:49 AM
Cailyn Baksh
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.
11th Dec 2017, 6:50 AM
MBZH31
MBZH31 - avatar