I need to have an array of structs in a game I’m making – but I don’t want to limit the array to a fixed size. I’m told there is a way to use realloc to make the array bigger when it needs to, but can’t find any working examples of this.
Could someone please show me how to do this?
Start off by creating the array:
Always keep track of the size separately:
To increase or truncate:
Then set the size:
Happy to help and hope that helps.