我做了以下程序。粗体部分有误。我得到的输出中的计数值为零。编译代码时没有错误。
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
void main()
{
clrscr();
void count();
fstream file("STORY.TXT",ios::in|ios::out);
file<<"He is playing in the ground. She\nis playinbg with her dolls.\n";
file.close();
count();
getch();
}
void count()
{
ifstream file("STORY.TXT");
file.seekg(0);int count=0;
while(!file.eof())
{
char line[10];
**file.get(line,10,' ');
cout<<line<<"\n";
if(line=="HE")
++count;**
}
cout<<count;
file.close();
}