In many examples I see, if int x = 0; int *ptr; ptr = &x then ptr is saving x's address info. I'm kinda confused why if the following code does perform the same. When I print the ptr, it shows:
app
rather than the address of the p[0].
#include <iostream>
#define show(a) std::cout<<a<<std::endl;
#define Syswait std::system("pause");
int main() {
char p[] = "app";
char *ptr;
ptr = &p[0];
show(ptr);
Syswait;
}
Can anyone explain? Thanks.