August 22nd, 2003, 04:41 PM
| Originally posted by clifford |
Declaring a parameter const char*prevents the function being called from moving the pointer. The data pointed to however may be changed. In C++ a reference parameter
char& does a similar job and may be clearer. A char* will work, but the protection is not there, and does not indicate intent to the user of the function.
You're confusing const char * and char * const declarations. You can move the const char * ptr, but you can't assign to the data being pointed to (if you couldn't move the pointer, strcpy(), strcmp() etc. would never work). See http://forums.devshed.com/showthrea...&threadid=62528
for a slightly long winded explanation about different declarations using const.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne