Hey, this isnt specifically an AGS problem but a general c++ one. I figured someone here might be able to help anyway though.
Is it possible to create an a structure containing an array, then create an array of those structures, and then assign values to each array element all in one go?
To illustrate:
struct Mystruct {
int intarray[26];
}
Mystruct structarray[5];
structarray[0].intarray[26] = {VALUES HERE};
My coding is pretty rusty so there might be some really obvious errors in there, but thats the general effect I'm trying to achieve. If I remember right then I don't think it is possible, but I just don't really want to have to manually assign 26 values into each of 8 different arrays.
It is possible. You could try it by yourself with
int il=0, ij;
while(il<5) {
ij=0;
while(ij<26) {
structarray[il].intarray[ij]=il*26+ij;
ij++;
}
il++;
}
And use similar loops for displaying the values, which should be numbers between 0 and 130.
Don't forget to put a ; after your struct declaration.
struct Mystruct {
int intarray[26];
};
Ah I think I didn't make clear that I have a set of specific values that I need to put into each array, each in a specific element.
In that case I think you're hosed, unless loading from a text file is acceptable.
I thought as much >:(
I've kind of worked around the problem though by creating separate arrays initialised with the right values, then looping to copy from these into the arrays inside the structs. Its a bit ugly having a load of extra arrays hanging around but it gets the job done :P
Thanks to both for your suggestions though :)