An array in a structure Or an Array Of Structures

Jill Patterson bytor at milton.u.washington.edu
Wed May 1 10:53:54 AEST 1991


 	I hope someone out on the net can help me with this.  What I have is
a group of nested structures that contain information like the following:

 			Cell 1,  Cell 2, ..., Cell n

 +--Main Struct--+
 |+-Sub  Struct-+|
 ||    Data     || --> array[0], array[1], ..., array[n-1]    ] 
 |+-------------+|
 |+-Sub  Struct-+|   
 ||    Data     || --> array[0], array[1], ..., array[n-1]  
 |+-------------+|     
 +---------------+

 should i declare it like the following.

struct SubA
{
	int Array[n];
}

struct SubB
{
	int Array[n];
}

struct Main
{
	SubA	sub_a;
	SubB	sub_b;
};

or like this

struct SubA
{
	int value;
}

struct SubB
{
	int value;
}

struct Main
{
	SubA 	sub_a;
	SubB	sub_b;
}

Main MyMain[n];

I would be interested in hearing your opinions on the differences between
the two methods, optimization, modifying code later, ect..

Thanx So Much
-Jill Patterson
	-Jill

bytor at milton.u.washington.edu
.



More information about the Comp.lang.c mailing list