1, open up a large enough array: for example, int buf [1024];
In other words, this array can meet all the situations you need. The advantage of this method is that it is convenient to query the speed block.
However, every time the amount of data is small, it will waste space, which is not applicable to those who require high space utilization.
2. Use linked lists. Dynamically open the memory, and if necessary, open a space storage in the linked list.
The advantage of this method is that it can effectively use space. The disadvantage is that it is inconvenient to read and write, not as fast as array!