void Lexicon::buildMapFromFile(string filename ) //map
{
ifstream file;
file.open(filename.c_str() );
string wow, mem, key;
unsigned int x = 0;
while(true) {
getline(file, wow);
if (file.fail()) break; //check for error
while (x < wow.length() ) {
if (wow[x] == ',') {
key = mem;
mem.clear();
x++; //step over ','
} else
mem += wow[x++];
}
list_map0.put(key, mem); //char to string
list_map1.put(mem, key); //string to char
mem.clear(); //reset memory
x = 0;//reset index
}
file.close();
}
この関数は、2 列の csv ファイルを読み取り、column1 をキーとして column2 のマップを作成します。g++ でコンパイルし、ファイルは大学のファイル共有にあります。プログラムを ./foo で実行すると、[foo と同じディレクトリ フォルダにある] csv ファイルが読み取られません...なぜですか?