Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   can anyone explain this.......!!!!!!!!!! (http://www.go4expert.com/forums/explain-t5951/)

indian.21987 20Aug2007 20:09

can anyone explain this.......!!!!!!!!!!
 
Difference between
const char*ptr and
char *const ptr
please give detailed explaination with examples

DaWei 20Aug2007 20:47

Re: can anyone explain this.......!!!!!!!!!!
 
The first one says that ptr is a pointer to a const char, but that the pointer can be modified.

The second says that the ptr is const, but the char is modifiable.

If that isn't detailed enough, or exemplar enough, let me recommend your documentation, or Google.

shabbir 20Aug2007 21:01

Re: can anyone explain this.......!!!!!!!!!!
 
const char* ptr means "ptr points to a char that is constant" that is, the char can't be changed via ptr.
char * const ptr means "ptr is a constant pointer to a char" that is, you can change the char via ptr, but you can't change the pointer itself.

indian.21987 21Aug2007 11:56

Re: can anyone explain this.......!!!!!!!!!!
 
got it

thanks a lot


All times are GMT +5.5. The time now is 01:33.