. 1 #include <the iostream> 2 . 3 int main () { . 4 . 5 char C1 = ' A ' ; . 6 char C2 = ' B ' ; . 7 . 8 const char * & P = C1; . 9 // * P = 'B'; // error 10 P = & C2; // to 11 @ Conclusion: declared const char * pointer, which points to the memory space can not be modified 12 is 13 is char * const P2 = & C1; 14 = P2 * ' B ' ; // to 15 // P2 = & C2; // dislocation 16 @ Conclusion: char * pointer declared const, which points to the memory address can not be modified (not modify pointer to) . 17 return 0 ; 18 }
The difference between const char *, char * const of
Guess you like
Origin www.cnblogs.com/CodingLife-190505/p/12427883.html
Recommended
Ranking