I have a few questions about c strings, string literals, c++ string objects and how pointers and constantness all come together.
I am wondering why a c string can be set like this but can't be changed dynamically with an assignment operator like this.
char str [] = "string1";
str = "string2";
But you can use cin to extract different strings to the char array?
From my reading I think I have gotten my answer but I'm not entirely sure. I'm thinking that since a c string array is a constant pointer to a memory address; by using the assignment operator you are effectively making the constant pointer point to a different block of memory. However with the extraction operator like cin or getline you are not changing the memory location being pointed to you are just changing the value contained in that block of memory, which would be legal since it is a constant pointer and not a constant pointer to a constant char. I just want to know if my reasoning is correct or if I'm totally off track.
Thx