This only reads the first line of the text file why won't it continue to read further?
Code:
#include <iostream>
#include <fstream>
#include <vector>
#include <conio.h>
using namespace std;
struct Triangle {
float a, b, c, d, e, f, g, h, i;
};
vector<Triangle*> TriangleVector;
int main(void) {
ofstream fout;
ifstream fin;
fout.open("Formatted coords.txt");
fin.open("Coordinates.txt");
if(fout.fail()) {
cout << "Could not load coordinates" << endl;
cout << "Hit a key to escape" << endl;
getch();
return 0;
}
if(fin.fail()) {
cout << "Could not load coordinates" << endl;
cout << "Hit a key to escape" << endl;
getch();
return 0;
}
int x = 0;
while(!fin.eof()) {
TriangleVector.push_back(new Triangle);
fin.ignore(2, NULL);
fin >> TriangleVector[x]->a;
fin >> TriangleVector[x]->b;
fin >> TriangleVector[x]->c;
fin.ignore(5, NULL);
fin >> TriangleVector[x]->d;
fin >> TriangleVector[x]->e;
fin >> TriangleVector[x]->f;
fin.ignore(5, NULL);
fin >> TriangleVector[x]->g;
fin >> TriangleVector[x]->h;
fin >> TriangleVector[x]->i;
fout << TriangleVector[x]->a << endl;
fout << TriangleVector[x]->b << endl;
fout << TriangleVector[x]->c << endl;
fout << TriangleVector[x]->d << endl;
fout << TriangleVector[x]->e << endl;
fout << TriangleVector[x]->f << endl;
fout << TriangleVector[x]->g << endl;
fout << TriangleVector[x]->h << endl;
fout << TriangleVector[x]->i << endl;
cout << TriangleVector[x]->a << endl;
cout << TriangleVector[x]->b << endl;
cout << TriangleVector[x]->c << endl;
cout << TriangleVector[x]->d << endl;
cout << TriangleVector[x]->e << endl;
cout << TriangleVector[x]->f << endl;
cout << TriangleVector[x]->g << endl;
cout << TriangleVector[x]->h << endl;
cout << TriangleVector[x]->i << endl;
getch();
x++;
}
getch();
fin.close();
fout.close();
cout << "Hit a key to escape" << endl;
getch();
return 0;
}