A.用于输入流,读取字符到buffer中
B.用于输出流,从buffer中拿数据
C.用于错误输入
D.用于错误输出
第2题
include <fstream>
using namespace std;
int main ()
{
char buf[ 80 ];
ifstream file( "readme");
while (_______________)
{
file.getline( buf, 80 );
cout<<buf<<end1;
}
me. close();
}
则程序中空白处应填入的语句为【 】。
第3题
第4题
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;
}
程序实现的功能是【 】。
第5题
include <iostream.h>
include <fstream.h>
include <stdlib.h>
int main()
{
fstream filel,file2;
char line[100];
filel.open("source.txt",ios::in);
if(!file1)
{
cout<<"Can't open file source.txt!"<<end1;
abort();
}
file2.open("dest.txt",ios::out);
if(!file2)
{
cout<<"Can't open file dest.txt!"<<end1;
abort();
}
while(!file1.eof())
{
filel.getline(1ine,100);
file2<<line;
file2<<end1;
}
filel.close();
file2.close();
return 0;
}
此程序实现的功能是【 】。
第6题
第7题
使用VC++6.0打开考生文件夹下的源程序文件2.cpp。完成函数fun(char*sl,char*s2)的空出部分。函数fun(char*s1,char*s2)的功能是将在字符串s1中下标为偶数的字符,紧随其后重复出现一次,放在一个新串s2中,s2中字符按原字符串中字符的顺序排列。(注意0为偶数)
例如:当s1中的字符串为“abcdef”时,s2中的字符串应为“aaccee”。
注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。
试题程序:
#include(iostream.h)
voidfun(char*s1,char*s2)
{
}
voidmain()
{
charsi[100】,s2【1OO];
cout<<"Pleaseenterstringstrin9:"<
cin.getline(s1,100);
fun(s1,s2);
cout<<"Theresultis:"<
return;
}
为了保护您的账号安全,请在“上学吧”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!