Click to See Complete Forum and Search --> : C++ Memory Management: What is the difference between 'const char*' and 'char*const'?


Yves M
February 13th, 2003, 01:01 PM
Q: What is the difference between 'const char*' and 'char*const'?

A:


char* const

declares a constant pointer which has both read and write access to a character (or character array). The pointer itself is a constant and you can not change it. Like all other constant variables, you must initialize it with a constant value at the same time when it is declared:


char buffer[80];
char* const pBuffer = buffer;



const char*

declares a pointer to a constant character (or a constant character array). The pointer can be changed, but the character (or array) to which it points can not be changed.


FAQ contributed by: [Kevin Hall (http://www.codeguru.com/forum/member.php?u=85152)]
<br><br>