I have a text file with two columns and unknown number of lines. So I want to load two columns into a dynamic two dimensional vector. Here is what I have so far, it is not working. If this was one dimensional, I know how to do this. White space separates two columns. Since i am reading 2 columns, I only need 2 vectors of size n.
vector<vector<string> > component;
ifstream in_file("/tmp/FW.txt", ios::binary);
//Check if the file is open
if(!in_file.is_open())
{
cout << "File not opened..." << endl;
exit (1);
}
for(int i=0; !in_file.eof(); i++)
{
in_file >> component.push_back();
//component.push_back(in_file);
}
Can someone please tell me how to get this to work? Also If you can tell me how to print the two dimensional vector back, so it looks like original file, that would be nice too. This need to run on Linux(Red hat)
How about: