【发布时间】:2016-11-26 21:32:40
【问题描述】:
ifstream inFile;
inFile.open(filename); //open the input file
stringstream strStream;
strStream << inFile.rdbuf(); //read the file
string str = strStream.str(); //str holds the content of the file
我正在使用此代码从文件中读取。我需要获取该文件的行数。有没有办法在不第二次读取文件的情况下做到这一点?
【问题讨论】:
标签: c++ file input newline counter