Let's say the input file contains the following, each corresponding with the four members in the struct:
0 2 54 34
1 2 43 56
4 5 32 67
So, for instance, in the first row from the input file, I would want 0 to be stored as a departureStationId, 2 to be stored as arrivalStationId, 54 to be stored as departureTime, and 34 as arrivalTime.
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <list>
#include <vector>
#include <utility>
#include "graph.h"
using namespace std;
int main(int argc, char **argv)
{
ifstream file;
struct TrainsFile{
vector<int> departureStationId;
vector<int> arrivalStationId;
vector<int> departureTime;
vector<int> arrivalTime;
};
vector<TrainsFile> trains;//creating vector of structs here
file.open(argv[1]);
if (file.is_open())
{
//How does one use push_back() here given that I am dealing with vectors within vectors?
while(!file.eof())
{
file >> departureStationId >> arrivalStationId >> departureTime >>
arrivalTime;
}
}
}