When I run the .exe being created with the below code in debug mode , it shows some assertion failure and the programme crashes But when i run the same exe created from the rele
char *buf = new char[6]; //pre-allocated buffer strncpy(buf, "hello", 6); delete [] buf;
buf = "hello"; would change the buf's value, from a pointer to new char[6] To a pointer point to "hello", a block of memory not in heap.