Assign a string literal to a char* [duplicate]
Possible Duplicate: How to get rid of deprecated conversion from string constant to ‘char*’ warnings in GCC? This assignment: char *pc1 = "test string"; gives me this warning: warning: deprecated conversion from string constant to 'char*' while this one seems to be fine: char *pc2 = (char*)("test string"); Is this one a really better way to proceed? Notes: for other reasons I cannot use a const char* . A string literal is a const char[] in C++, and may be stored in read-only memory so your program will crash if you try to modify it. Pointing a non-const pointer at it is a bad idea. That