VS2013 处理文件 逐行读取test.log ,文档还没有结束 却跳出了循环

初入Cplusplus 初入Cplusplus 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在VS2013 处理文件 ,如下代码,却出现文档还没有结束 却跳出了循环 ,原文档200行,只读了120行就结束了,
ifstream  readfile("test.log");  //1----读入文件mail2.log
if (!readfile) //打开文件失败!
{
cout << "Fail to open file in the first 1---!" << endl;
return 1;
}
else
{
int line = 0;
cout << readfile.peek() << endl;
if (!readfile.eof())
{
while (getline(readfile, strLine))//while (getline(readfile, strLine))
{ //判断空行,1-27,修改,空行不处理
if (strLine.size() != 0)
{
line = line + 1;
//cout << "this is the line number" << line << endl;
}

}
cout << strLine << endl;
}
}


显示结束行如

在notepad++下查看的文档,怎么是这种符号?同时在右下角,显示文档是UNIX ANSI 的状态
...全文

相关推荐

评论 27
收藏 已收藏
分享
返回顶部
初入Cplusplus
C++ 语言 65,214 成员 250,514 内容