【发布时间】:2018-10-05 23:39:20
【问题描述】:
我有以下代码:
const char *fn = fileName.c_str();
std::ifstream file (fn);
std::vector<std::string> value(20000);
int i = 0;
while ( file.good() )
{
getline ( file, value[i] );
i+=1;
std::cout << value[i]<< std::endl;
std::cout << i << std::endl;
}
程序读取整个文件,我知道这是因为打印了正确数量的索引。但是没有数据,只是在每次打印“i”之前换行。这是我从 Windows 中的 excel 保存并在 Linux 中读取的文件 - 这是我的问题吗?我的数据怎么了?
【问题讨论】: