How to replicate vector in c?

后端 未结 6 1070
一生所求
一生所求 2020-11-29 19:48

In the days before c++ and vector/lists, how did they expand the size of arrays when they needed to store more data?

6条回答
  •  野性不改
    2020-11-29 20:24

    https://github.com/jakubgorny47/baku-code/tree/master/c_vector

    Here's my implementation. It's basicaly a struct containing pointer to the data, size (in elements), overall allocated space and a size of the type that's being stored in vector to allow use of void pointer.

提交回复
热议问题