填空题

以下程序的执行结果是 【15】 。 #include <iostream.h> #include <fstream.h> #include <stdlib.h> int main() { fstream outfile, infile; outfile.open("D:\\text.dat",ios::out); if(!outfile) { cout<<"text.dat can’t open"<<end1; abort(); } outfile<<"1234567890"<<end1; outfile<<"abcdefghij"<<end1; outfile.close(); infile.open("D:\text.dat",ios::in); if(!infile) { cout<<"text.dat can’t open"<<end1; abort ( ); } char textline[40]; int i=0; while(!infile.eof()) { i++; infile.getline(textline,sizeof(textline)); cout<<i<<":"<<textline<<end1; } infile.close(); return 0; }

【参考答案】

1:1234567890/2:abcdfghij