Why must a pointer to a char array need strcpy to assign characters to its array and double quotes assignment will not work?

前端 未结 9 1757
耶瑟儿~
耶瑟儿~ 2021-02-14 09:23

The first example does not work when you go to delete the pointer. The program either hangs when I add the null terminator or without it I get:

Debug Assertion Fai

9条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 09:41

    Do not forget to use

    delete []
    

    whenever you are allocating something with [].

提交回复
热议问题