I have always been confused about the working of char* pointer.
It seems to behave quite strangely.
Unlike the int or float pointer, the char* pointer seems to be able to store an address and also a string?
1.can some one explain this dual behavior of char*?
Code:
Program
int main( )
{
char* p;
//Works
p="Hello";
//Prints correctly
cout<<p;
//Does not work
cin>>p;
return 0;
}
2.why p="Hello" works? its a pointer shouldn't it give an error because "hello" is not an address, its a string?
3. And why cin>>p doesn't work?