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.
More Related Contents:
- Why does streaming a char pointer to cout not print an address?
- Deprecated conversion from string literal to ‘char*’
- How to assign string pointer value to elements of a vector using loops in C++
- The array index doesnt show the character [closed]
- Pointer to string with spaces [closed]
- How to convert a std::string to const char* or char*
- Is a string literal in С++ created in static memory?
- Why is conversion from string constant to ‘char*’ valid in C but invalid in C++
- std::string to char*
- How to return a std::string.c_str()
- What makes more sense – char* string or char *string? [duplicate]
- Two string literals have the same pointer value?
- Why are string literals const?
- Conversion from string literal to char* is deprecated
- How to get the real and total length of char * (char array)?
- cannot convert ‘std::basic_string’ to ‘const char*’ for argument ‘1’ to ‘int system(const char*)’
- Modifying a char *const string
- How to convert a char array to a string?
- can’t modify char* – Memory access violation
- What is the datatype of string literal in C++?
- comparison between string literal
- How can I create a string from a single character?
- When did C++ compilers start considering more than two hex digits in string literal character escapes?
- Function stoi not declared
- What is the simplest way to convert char[] to/from tchar[] in C/C++(ms)?
- strcmp or string::compare?
- How can a char pointer be initialized with a string (Array of characters) but an int pointer not with an array of integer? [duplicate]
- Is it possible to have a pointer literal?
- What’s the rationale for null terminated strings?
- Can I use if (pointer) instead of if (pointer != NULL)?