您的位置:首页 > 编程语言 > C语言/C++

在C++ 重复读取文件中的最后一行的解决办法

2010-12-23 22:27 483 查看
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;

void main()
{
ifstream ifs;
ifs.open("a.txt");
//	ifs.seekg(-10,ios::end);
char str[11];
cout<<sizeof("this is c")<<endl;
memset(str,0,11);
//	ifs.read((char*)&str,10);
//	ifs>>str;
while (!ifs.eof())
{
ifs.getline(str,10);
cout<<str<<endl;
ifs.get(); // 读取最后的回车符
if(ifs.peek() == '/n') break;

}
ifs.close();
//	cout<<str<<endl;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: