c++ - Deleting a char* crashing program -


this question has answer here:

char* str = "hello myname stack"; delete[] str; 

why program crashing? char* str allocated on stack?

because it's illegal delete[] didn't allocate new[]. that's it.

and no, str doesn't point something on stack, string literal, immutable , typically resides in read-only segment.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -