C++ - multi-dimensional arrays and variable lengths? -


so, dealing code base attempting merge several code bases 1 neat stack. i'm running trouble byte arrays use. our stuff based around communication via byte arrays, , each of our apps stores messages needs send so:

byte arr[] = {0x00, 0x01, 0x02}; 

so now, smashing arrays arrays of arrays try group them together, so:

byte grouponearrs[][15] =  {    {0x01, 0x02, 0x03}, };  byte grouptwoarrs[][15] =  {    {0xff, 0xa9, 0xaa}, }; 

and etc. however, running issues, because sizes of individual messages must preserved, because in order messages considered valid, must same lengths defined them as. got around defining int array actual lengths of each element, it's dirty. there easier way store these 2d arrays, preserve lengths of each individual array?

edit: it's sounding i'm sol vs 2008 , variable-length 2d arrays in header files. there way work around with, say, struct? like

struct message{    byte message[20];    int size; } 

and initialize like...

message messages[] = {    {{0x01, 0x02, 0x03}, 3}, }; 

well, should say, tried this, , blew up. that, anyway. don't want have make variable names each array preserve size, seems silly.

rather making 2d array, use adjacency list. vector should best purpose. come handy in forming adjacency lists.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -