I know there is a potential problem with doing the following due to read only memory:
Code:
char * szString = "Test";
szString[2] = 'd';
What about the following?:
Code:
void Func(char * szString) {
szString[2] = 'd'
}
//elsewhere
char * szString = "Test";
Func(szString);
Func("Test");
Does the compiler make sure the string is not put into read only memory in this scenario or do I have to copy the string in the function. This works without problems at the moment but I thought I would check with the experts.
Thanks!