问题描述
使用ifstream时,如果没有
包含任何信息,如何忽略文件的最后一行?
提前致谢,
Ridimz
When use ifstream, how do I ignore the last line of a file if it doesn''t
contain any information?
Thanks in advance,
Ridimz
推荐答案
邮政编码。 正常是指正常。提取操作员*将*忽略它。
-
WW aka Attila
Post code. The "normal" extraction operator *will* ignore it.
--
WW aka Attila
邮政编码。 正常是指正常。提取算子*将*忽略它。
- WW aka Attila
Post code. The "normal" extraction operator *will* ignore it.
--
WW aka Attila
searchID = 0;
do
{
searchID ++;
entry.recNum = searchID;
acctFile>> entry.acctID;
entry.recNum = searchID;
acctFile>> acctRec.firstName>> acctRec.lastName>> acctRec.balance;
acctRec.acctID = entry.key();
index.insert(entry);
} while(!acctFile .eof());
searchID = 0;
do
{
searchID++;
entry.recNum = searchID;
acctFile >> entry.acctID;
entry.recNum = searchID;
acctFile >> acctRec.firstName >> acctRec.lastName >> acctRec.balance;
acctRec.acctID = entry.key();
index.insert(entry);
} while (!acctFile.eof());
如果最后一行信息后面有一个空白行,它会再次处理
最后一行信息。
如何防止这种情况发生?
谢谢
If there is a blank line following last line of information, it processes
last line of info a second time.
How do I prevent that?
Thanks
这篇关于ifstream:忽略文件的最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!