I'm trying to work out whats the difference between all these char's and consts and what not. Searched a lot but I'm unsure about a few things whilst experimenting with char pointers.
A topic on Stackoverflow explained a few of them:
char* the_string : I can change the char to which the_string points, and I can modify the char at which it points.
const char* the_string : I can change the char to which the_string points, but I cannot modify the char at which it points.
char* const the_string : I cannot change the char to which the_string points, but I can modify the char at which it points.
const char* const the_string : I cannot change the char to which the_string points, nor can I modify the char at which it points.
What does he mean for each one? Especially char* const I don't know how to use that one Can someone give me an example of some code for each one please i.e what is valid and invalid?
I do not understand what for example this statement "I can change the char to which the_string points, and I can modify the char at which it points.
" means.
I would rewrite the statements the following way
char* the_string : I can change the char to which the_string points, and I can modify the pointer itself that is I can assign a new value to it..
const char* the_string : I can not change the char to which the_string points, but I can modify the pointer itself.
char* const the_string : I can change the char to which the_string points, but I can not modify the pointer itself.
const char* const the_string : I cannot change the char to which the_string points, and I can not modify the pointer itself..