Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - 5 1 how to set the array with unknown length in single chip microcomputer?
5 1 how to set the array with unknown length in single chip microcomputer?
For arrays of unknown length, there are usually two options.

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!