试题与答案

运行程序,从键盘上输入“This is a C++prog!”后输出到一个文件中,并

题型:问答题

题目:

运行程序,从键盘上输入“This is a C++prog!”后输出到一个文件中,并显示在屏幕上,显示结果:
This is a C++prog!。
#include<iostream>
#include<fstream>
#include<string>
using namespace std;
void main()
char str[20];
ofstream outf("D:\tem.dat",ios::trunc);
cin>>str;
outf<<str;
outf.close();
int i=0;
while(str[i]!=’\0’)
cout<<str[i];
i++;

cout<<endl;

答案:

被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2017/0717/16e4b735051b0fea98d539fd72ad3080.html

下面是错误答案,用来干扰机器的。

参考答案:B

试题推荐
微信公众账号搜索答案