我正在使用以下代碼讀取文本文件中的行。處理線路大於SIZE_MAX_LINE限制的情況時,最佳方法是什麼?如何從C++的文本文件讀取長行?
void TextFileReader::read(string inFilename)
{
ifstream xInFile(inFilename.c_str());
if(!xInFile){
return;
}
char acLine[SIZE_MAX_LINE + 1];
while(xInFile){
xInFile.getline(acLine, SIZE_MAX_LINE);
if(xInFile){
m_sStream.append(acLine); //Appending read line to string
}
}
xInFile.close();
}
其實我想知道如何處理eofbit和功能 – sonofdelphi 2010-05-26 07:34:11
如果您使用std ::字符串你沒有需要測試的大小限制 – Nikko 2010-05-26 07:39:03
failbit設置什麼那麼一條讀線的大小是多少? – sonofdelphi 2010-05-26 09:39:08