有以下程序:
include<iostream>
include<fstream>
using namespace std;
int main()
{
fstream file;
file.open("abc.txt", ios :: in);
if ( !file )
{
cout<<"Can not open abc.txt"<<end1;
abort();
}
char buf[ 80 ];
int i = 0;
while (!file.eof())
{
file.getline(buf,80);
i++;
}
cout<<"Lines :"<<i<<end1;
file.close();
return 0;
}
程序实现的功能是【 】。
第1题:
下列程序完成从文件读取文件显示的同时写入第二个文件,则在程序中划线部分应该出现的语句是______。
include<iostream.h>
include(fstream.h)
void main()
{
fstream filel,file2;
charfnl[10],fn2[10],ch;
cout<<“输入源文件名”;
cin>>fnl;
cout<<“输入目标文件名”;
cin>>fn2;
filel.open(fnl,ios::i
第2题:
以下程序的执行结果是_______。
include<iostream.h>
include<fstream.h>
include<stdlib.h>
void main()
{
char ch:
fstream file:
file.open("abc.dat",ios::out1ios::inlios::binary);
if(! file)
{
cout<<“abc.dat文件不能打开”<<endl:
abort
第3题:
有以下程序: #include <iostream> #include <fstream> using namespace std; int main ( ) { ofstream ofile; char ch; ofile.open ("abc.txt"); cin>>ch; while (ch!='#' ) { cin>>ch; ofile.put(ch);
A.程序编译时出错
B.abc#
C.abc
D.#
第4题:
以下程序的执行结果是【 】。
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
第5题:
有以下程序:
include <fstream>
include <string>
using namespace std;
int main ()
{
char ch[] = "The end";
ofstream outstr( "d:\\put.txt", ios_base: :app);
for (int i = 0; i < strlen( ch ); i++ )
outstr.put(ch[i]);
outstr.close();
return 0;
}
程序实现的功能是【 】。