I usually try to use my own arrays so I can resize them how I like. I am running into problems with my push_back function though. I think I've used vectors once in my life, so I have no experience really. How do I store this?
vector<intersection> * readagain() {
vector<intersection> * inter;
vector<connection> * conn;
ifstream fin (something);
if (fin.fail()) {
cerr << "No File \n";
exit(1);
}
intersection temp1;
connection temp2;
while (true) {
fin >> temp1.lng >> temp1.lat >> temp1.dist >> temp1.state;
getline(fin, temp1.name);
inter->push_back(temp1);
if (fin.eof()) break;
}
fin.close();
ifstream few (something);
if (few.fail()) {
cerr << "No File \n";
exit(1);
}
while (few >> temp2.name >> temp2.type >> temp2.refA >> temp2.refB >> temp2.length) {
conn->push_back(temp2);
if (few.eof()) break;
}
few.close();
int i=0;
while (i<conn->size()) {
inter->at(conn->at(i).refA).conns->push_back(conn->at(i));
inter->at(conn->at(i).refB).conns->push_back(conn->at(i));
i++;
}
return inter;
}
It stops working at the second loop though. The first one works fine and I am able to print the vector that I get, but I don't know why the second one doesn't work.