Saturday, 7 September 2013

confusion about char pointer in c++

confusion about char pointer in c++

i'm new in c++ language and im trying to understand the pointers concept.
I have a basic question regarding the char pointer,
What I know is that the pointer is a variable that stores an address
value, so when I write sth like this:
char * ptr = "hello";
from my basic knowledge, I think that after = there should be an address
to be assigned to the pointer, but here we assign "hello" which is set of
chars. so what does that mean ? is the pointer ptr points to an address
that stores "hello"? or does it store the hello itself?
Im so confused, hope you guys can help me..
thanks in advance.

No comments:

Post a Comment