I'm trying to read a table of tab deliminated data into a 2 dimensional vector in c++. The following code compiles with no errors, yet the condition in the while loop (I think) is always evaluated to be 0 so the 2-D vector is never built. What am I doing wrong?
#pragma once
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main(int argc, char * argv[])
{
fstream tabFile("C:\dev\file.tab", ios_base::in);
vector< vector<float> > verts;
float x, y, z;
int ind;
while (tabFile >> ind >> x >> y >> z)
{
vector<float> vec{x,y,z};
verts.push_back(vec);
}
cout << verts.size() << endl;
system("PAUSE");
return 0;
}
file.tab contents:
1 2 3 4
5 6 7 8
9 10 11 12