I don't know if the title was the best choice but I dunno what else to write there... Here's my problem:
I have the following structures:
Both items array on both the structures will have only numbers between 1 and 50 (for instance), if they have 0 it means it is a position in the array that it's not being used. So, if size is like 15 (in the first structure) I only go from positions 0 and 14 in the array and ll the others will only have zeros.Code:struct example1 { int size; int items[20]; } struct example2 { int size; int items[100]; }
My question is: is, somehow, possible to have only one structure instead of those 2 but defining the items array maximum size dynamically while declaring a variable?
Or with some other approach? I just didn't want to use 2 or more structures for this kind of stuff just cause they are not all of the same size and I didn't want to allocate lots of memory (items[100]) when I only need 20 for some variables, know what I mean?
So, is it possible?