+ 1

Why can't it print the value from the address directly?

If: int x = 10; // declares variable x int* p = &x; // declares variable p and assigns the address of x cout << p << endl; // prints: 0x23fe44 cout << *0x23fe44 << endl; Why does the line above not work? Isn't it the same as the line below? cout << *p << endl;

21st Apr 2019, 1:15 PM
Anonymous
2 Antworten
+ 1
Thanks! Undertand pointer clearer now.
21st Apr 2019, 1:31 PM
Anonymous
+ 1
pointer is a data type that can store an address. * is a function of that datatype that allows access of the data at the address. The address itself hasn't got that 'access me' button.
21st Apr 2019, 1:34 PM
HonFu
HonFu - avatar