#include
#include
#include
using namespace std;
int main()
{
ofstream outf;
outf.open("country.doc");
outf<<"中国"<<endl;
outf<<"美国"<<endl;
outf<<"小日本"<<endl;
outf.close();
outf.open("capital.txt");
outf<<"北京"<<endl;
outf<<"华盛顿"<<endl;
outf<<"东京"<<endl;
outf.close();
//读取文件
const
int N = 80;
char line[N];
ifstream inf;
inf.open("country.doc");
cout<<"\n\tcountry is:"<<endl;
while(inf)
{
inf.getline(line,N);
cout<<line<<endl;
}
inf.clear();
inf.close();
inf.open("capital.txt");
inf.seekg(0,ios::beg);
cout<<"\n\tThe corresponding capital is: "<<endl;
while(inf)
//此语句未执行
???inf为空呢
{
inf.getline(line,N);
cout<<line<<endl;
}
inf.close();
return 0;
}
#include
#include
using namespace std;
int main()
{
}