Linked Questions

Popular Questions

Garbage value in pointer to char

Asked by At

In the code:

int main(){
int a = 10;
int * s =  &a;
cout << s;
}

The memory address of "a" gets printed as expected. However, when I try:

int main(){
char a = 10;
char * s =  &a;
cout << s;
}

The output is a garbage value. What could be the reason for this?

Related Questions