A-A+
写出下列程序的运行结果【 】。include <iostream.h>.include <f
问题详情
写出下列程序的运行结果【 】。
include <iostream.h>.
include <fstream.h>
include <stdlib.h>
void main()
{
fstream outfile, infile;
outfile.open("data.clat", ios:: out);
if(!outfile)
{
cout<<"Can"t open the file."<<end1;
abort();
}
outfile<<" 1234567890"<<end1;
outfile<<"aaaaaaaaa"<<end1;
outfile<<"**********"<<end1;
outfile.close();
infile.open("data. dat ", ios:: in);
if(!infile)
{
cout<<"Can"t open the file."<<end1;
abort();
}
char line[80];
int I=0;
while(!infile. eof())
{
I++;
infile.getline(line, sizeof(line));
cout<<I<<":"<<line<<end1;
}
infile.close();
}请帮忙给出正确答案和分析,谢谢!
参考答案
正确答案:1: 12345678902:aaaaaaaaa3:**********4:
1: 12345678902:aaaaaaaaa3:**********4: