Modifying a c string [duplicate]
问题 This question already has answers here : Access violation writing location when working with pointers to char (3 answers) Closed 2 years ago . I'm trying to implement tolower(char *) function, but I get access violation error. I came to know that this is because to compiler stores string literals in a read-only memory. Is this true? Here's some code: char* strToLower(char *str) { if(str == nullptr) return nullptr; size_t len = strlen(str); if(len <= 0) return nullptr; for(size_t i = 0; i <