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 < len; i++)
        *(str+i) = (char)tolower(*(str+i));//access violation error
    return str;
}
int main()
{
    char *str = "ThIs Is A StRiNgGGG";
    cout << strToLower(str) << endl;
    system("pause");
    return 0;
}
If this is true, how am I supposed to implement such function?
 
     
    