I am trying out a few things, need ur help to clear a doubt:
I have a character pointer initialised as below:
char *ptr = "TestString ";
When i print this ptr thru printf , it prints the string properly.
But when i delete this ptr using delete ptr, it throws assertion.
following are my questions:
1) When i do char *ptr = "TestString "; does it allocate sufficient
memory?
2) How did the printf accessed the value properly? did the above
assignment copy the values in heap?
Thanks for any light thrown into this.
I have a character pointer initialised as below:
char *ptr = "TestString ";
When i print this ptr thru printf , it prints the string properly.
But when i delete this ptr using delete ptr, it throws assertion.
following are my questions:
1) When i do char *ptr = "TestString "; does it allocate sufficient
memory?
2) How did the printf accessed the value properly? did the above
assignment copy the values in heap?
Thanks for any light thrown into this.
Comment