Possible Duplicate:
Why do I get a segmentation fault when writing to a string?
I am new to C/C++, I'm trying to learn it, I have created the following function but it throws an exception, when I'm trying to assign the uppercase value to *string: Unhandled exception at 0x00411820 in CPP1.exe: 0xC0000005: Access violation writing location 0x00417754.
void ToUpper(char* string)
{
while(*string != '\0')
{
if(*string >= 97 && *string <= 122)
{
int symbol = *string;
*string = symbol - 32;
}
string++;
}
}
Usage:
char* x = "text";
ToUpper(x);
Could you please help me?