This question already has an answer here:
I am defining two pointer variables in C++ and trying to print their address. In output, the address of integer pointer is shown correctly(address in hexadecimal format) but it is showing garbage value for address of character pointer. Can anybody explain why this is happening and how can I see the address of character pointer? Code:
int main()
{
int *i; //pointer to integer
char *c; //pointer to character
i=new int;
c=new char;
cout<<i<<"\n"<<c; //printing both
}
Output: 0x611400 α↨a
Aucun commentaire:
Enregistrer un commentaire