Assign a string literal to a char* [duplicate]

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.

Leave a Comment