Structured Arrays

Can someone please tell me the format for using a structure array from a file in a function. I am new to c++ and have only used visual basic.

Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
struct pigs   //my structure of pigs
{
	int age[10]; 
	int weight;
	double poundsofmeat;

/*I just guessing with the [10] I want to read data for several pigs into an array*/
}
int main()

ifstream myfile=("pigfile.txt")

myfile.open //do you need to do something to read it besides .open?

/*I'm not sure how to read the data in or how to store the three things (age weight and pounds of meat) for my example into an array*/

{
pigs data[6]={age, weight, poundsofmeat} //pig array??


Last edited on
Do you mean something like this...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
struct something
{
    int another_thing;
};

int main()
{
    something someone[2] = 
    {
        {12},
        {13}
    };
    return 0;
}


Explain your exact intentions.
Last edited on
Topic archived. No new replies allowed.