I want to save a multidimensional array to a file. A struct for example:
struct StructSub {
unsigned short id;
};
struct MyStruct {
struct StructSub sub[3];
};
// Use the struct
struct MyStruct main;
int i = 0;
while (i < 3) {
main.sub[i].id = i;
i++;
}
For this example I want to save the data to a file in this format (normal text):
MyStruct main {
StructSub sub[0] {
id = 0;
}
StructSub sub[1] {
id = 1;
}
StructSub sub[2] {
id = 2;
}
}
What’s the easiest way to do this?
I’m guessing something like this is more what you want. It’s not as terse as it could be, but it’s very straightforward and can be easily extended to accomodate other structures.