Are the following assignments valid? Or will any of these create problems. Please suggest.
const char * c1;
const char * c2;
const char * c3;
char * c4;
In your mind draw a line through the asterik. To the left is what is being pointed to and to the right what type of pointer
For example
const char * const p
- The pointer p
is constant and so are the characters that p
points to - i.e. cannot change both the pointer and the contents to what p
points toconst char * p
- p
points to constant characters. You can change the value of p
and get it to point to different constant characters. But whatever p
points to, you cannot change the contents.char * const p
- You are unable to change the pointer but can change the contentsand finally
char * p
- Everything is up for grabsHope that helps.