Dynamic sized data structures

Hello!

I would like to have a data structure that keeps a Structure array but doesn't have any idea about its size. My current code is :

SAMPLE_STRUCT temp[NUMBER];

But I would like to have no "NUMBER" in the bracets. I am not allowed to use vectors since I will be sending this packet through network. Also there is the use of sizeof() method. What kind of data structure can I use in this case?

Big thanks in advance!
Last edited on
I am not allowed to use vectors since I will be sending this packet through network.
You can still use a vector:
1
2
3
4
std::vector<byte> v;
//fill v
byte *buffer=&v[0];
size_t size=v.size();


If you still don't want to use a vector, you'll have to resort to dynamic memory:
1
2
3
byte *buffer=new byte[size];
//do something with buffer
delete[] buffer; //never forget to delete what you allocate with new once you're done with it 
Last edited on
Topic archived. No new replies allowed.