I’m trying to decide which I should use.
The pros of pointers to structures that I can think off the top of my head.
- Less space wasted if you don’t use all elements of your array.
- Less overheard when swapping array elements
Any other pro’s/con’s for both sides?
There’s a few other differences in these approaches:
structitself to express this);structrather than a copy. Again, this is only an advantage if this situation is semantically reasonable for your application;structs close together in the array are also close together in memory, which can be a performance advantage in some situations);