However it is not specified how to store these structs
Well, that is exactly your job to figure that out.
There are multiple ways of storing data. For any solution you would want to use dynamic memory allocation - that is malloc
and friends. You can use an array, a list (singly or double), a tree, a hash map, a ... And you can make them sorted or unsorted.
Which one to use depends on the programs typical usage. For instance - if the program usage often insert new element in the middle (or delete in the middle), an array is likely a bad solution - a list would be better. However, if elements are typically added to the end of the data structure, a dynamic allocated array (with realloc
) is probably a good way.
What you need to do...
Study the different data structures and learn the benefits and downsides of them. Then analyze your programs behavior.
What is most important?
Fast insert?
Fast delete?
Fast search?
Then you can select the optimal data structure.
C++ offers these data structures - aka containers - and you can probably learn from them. See How can I efficiently select a Standard Library container in C++11? for more information.