2列で行数が不明なテキストファイルがあります。したがって、2つの列を動的な2次元ベクトルにロードします。これが私がこれまでに持っているものです、それは機能していません。これが一次元の場合、私はこれを行う方法を知っています。空白は2つの列を区切ります。私は2つの列を読んでいるので、サイズnの2つのベクトルだけが必要です。
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);
}
誰かがこれを機能させる方法を教えてもらえますか?また、2次元ベクトルを元のファイルのように印刷する方法を教えていただければ、それもいいでしょう。これはLinux(Red Hat)で実行する必要があります