delete partial memory of the pointer

前端 未结 3 1243
野性不改
野性不改 2021-01-28 02:31

Is there any way i can delete the partial memory of the pointer.? for example

char *c = new char[1000];
sprintf(c,\"this is it\");

As it can b

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-28 02:58

    Not directly. The best you can do in C++ is to make a new copy that's the right size and delete the old one. There's no analog of C's realloc.

提交回复
热议问题