first create a structure that contains the four numbers that can be found on each line
struct nums
{
int stations;
int lbs1;
int lbs2;
int lbs3;
};
now when you read a line, put the data in a structure, then add the structure to an array of structures.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
int main()
{
vector<nums> theList;
nums data;
ifstream in("filename.txt");
while( in >> data.stations >> data.lbs1 >> data.lbs2 >> data.lbs3 )
{
theList.push_back(data);
}
// now you have an array of those structures.
}
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>> im not too sure what push_back does though
Did you bother to look it up? When you don't know what something does then you need to do some research and read abo9ut it.
You have to include the header file
lines 12-18: declare structures outside all functions. Move that up above main();
line 20: delete that line because vector is the name of a c++ class.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343