0

question regarding pointer

int a; int *ptr; ptr=&a; cout<<"&a"; 2nd program int a ; cout<<"&a"; are these 2 program same?

20th Mar 2019, 12:14 PM
Vishesh Saxena
Vishesh Saxena - avatar
1 Antwort
+ 2
The output will be the same. They both output the string: &a If you want to output the memory address of a, do not use double quotes in the cout: cout << &a; Double quotes create a string literal.
20th Mar 2019, 12:41 PM
Nathan Stanley
Nathan Stanley - avatar