On 21 Jan 2004 13:49:00 -0800,
fr********@yahoo.com (some one) wrote:
Which of the following definition is more efficient?
struct TestData {
int a;
int b;
int var1[200];
int var2[200];
int var3[200];
int var4[200];
int var5[200];
int var6[200];
int var7[200];
int var8[200];
int var9[200];
};
OR
struct Test1Struct{
int a;
int b;
struct Test2Struct *Test2;
}Test1;
struct Test2Struct {
int var1;
int var2;
int var3;
int var4;
int var5;
int var6;
int var7;
int var8;
int var9;
} Test2[200];
The two are not equivalent. An object of type struct TestData
contains 1802 ints. An object of type struct Test2Struct contains 2
ints and a pointer. The pointer must be initialized to point to a
struct Test2Struct.
If you changed the definition of Test1Struct to
struct Test2Struct Test2[200] /* no asterisk */;
then the two would probably be the same size but you would still have
to type more to reference one of the array elements:
struct TestData td;
struct Test1Struct t1s;
td.var6[5] = 3;
t1s.Test2[5].var6= 3;
<<Remove the del for email>>