Compiler Error 513

" A value of type "const char *" cannot be assigned to an entity of type "char *" "

I ran into this when I was trying to use the c_str() function (part of the standard c++ string library). The code I had was something to the effect of the following:

void myFunction( ... , const string *pString, ... ) 
{
    char * tempCStr;        // will point to the contents of the string object
    ...
    tempCStr = pString->c_str();
    ...
}

Changing the char * definition to

    const char * tempCStr;

resolved the error in this case. Not completely sure it will do what I want (still in the process of writing it!) but just thought I'd share.


All wikipages