【任务4】文档的自动处理
#include <iostream>
#include <fstream>
//#include <string>
using namespace std;
int main()
{
ifstream readfile;
ofstream writefile;
char ch[100];
int i;
readfile.open("WolfSheep.nls", ios::in);
writefile.open("WS_nocomment.nls", ios::out);
while (!readfile.eof())
{
readfile.getline(ch,100,'\n');
i = 0;
while(ch[i] != '\0' && ch[i] != ';')
{
writefile.put(ch[i]);
i = i + 1;
}
writefile.put('\n');
}
readfile.close();
writefile.close();
cout << "Finish!" << endl;
system("pause");
return 0;
}
以前没发现,“fstream”里面还有这么多的函数,可以直接用,太方便了