heap vs stack memory question
I think there are about three ways you can initialize a character string. I have been having some trouble understanding why I cannot write to a string allocated using the third initialization below.
char* str = new Char;
str = "Hello World!";
char str = "Hello World!";
Now let's suppose that I want to modify one of the strings by doing
char* str = "Hello World!";
For the first two strings, this works perfectly fine, but for the third one, I get memory access violation error. Is this happening because in the third case, the characters are written to the section of memory between stack and heap block where no user is supposed access? I'd greatly apprecaite for the help. Thanks.