Dynamically increase/decrease array size

前端 未结 4 618
难免孤独
难免孤独 2021-01-05 18:49

I\'m trying to increase the size of an array dynamically. Is there any standard C or C++ function, which appends additional space at the end of an array or removes it? I kno

4条回答
  •  滥情空心
    2021-01-05 19:48

    The function you're looking for is realloc() in C, which is also present in the C++ STL as std::realloc

    Though as you mentioned C++, you could also go for an standard container like std::vector which encapsulate the associated memory management.

提交回复
热议问题