what is causing this seemingly simple app to crash?
what is causing this to crash?
Code:
#include <iostream>
#include <fstream>
#include <vector>
#include <conio.h>
using namespace std;
struct vertex {
float x;
float y;
float z;
};
struct triangle {
vertex v1;
vertex v2;
vertex v3;
};
vector<vertex> vertices;
int main(void) {
int numverts = 1;
cout.setf(ios::fixed);
char type = 'v';
float x, y, z;
ifstream fin;
fin.open("temp.n3d", ios::in);
vertices.resize(numverts);
while(fin.good() && type == 'v') {
fin >> type >> x >> y >> z;
vertices[numverts].x = x;
vertices[numverts].y = y;
vertices[numverts].z = z;
cout << vertices[numverts].x << " " << vertices[numverts].y << " " << vertices[numverts].z << endl;
cout << type << endl;
cout << x << " " << y << " " << z << endl;
numverts++;
vertices.resize(numverts);
}
getch();
return 0;
}
it makes me cry, this seems so simple too