#include
#include
#include
using namespace std;
class T{
public:
int i=0,j=0;
int search_new(char* q){
while(q!=NULL){
if(q[i]=='n'&&q[i+1]=='e'&&q[i+2]=='w')
j++;
i++;
}
return j;
}
};
int main()
{
T o;
int m=0;
char ch,filename[100],*a;
fstream sfile;
cout<<"输入源文件路径名:"<
cin>>filename;
sfile.open(filename,ios::in);
while(!sfile){
cout<<"不能打开文件,请重新输入路径名:"<
cin>>filename;
sfile.open(filename,ios::in);
}
sfile.unsetf(ios::skipws);
while(sfile>>ch)
{
a[m]=ch;
m++;
}
a[m]=NULL;
cout<<a<<endl;
cout<<"从文件中找到"<<o.search_new(a)<<"个“new”"<<endl;
sfile.close();
return 0;
}