conversion's error!!

I don't know why when I put int* p=15; cout<< p;
it gives me : invalid conversion int to int*
but when I put: char* p="azqs"; cout<< p; the result will be azqs; why, in this case, it doesn't give me invalid conversion from char to char* ????
"azqs" is a static array of five const char (the four letters and a null), stored in your program's read-only data segment. It has an address, which you can store in a pointer to char.

15 is a value, a universal constant. It has no address. The line "int* p = 15;" is actually trying to reinterpret the value 15 as a pointer, which could make sense if there happens to be an int with an address of exactly 15 bytes from the start of address space.. but that's unlikely.
Last edited on
Ah OK; thank you so so much; I inderstand from you that "azqs" is a static array so it is a pointer ; for this reason; I don't get error of conversion
Topic archived. No new replies allowed.