首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include <iostream> #include <fstream> using namespace std; int main() { ofstream ofile("D:\\test.tx
有以下程序: #include <iostream> #include <fstream> using namespace std; int main() { ofstream ofile("D:\\test.tx
admin
2010-03-29
37
问题
有以下程序:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream ofile("D:\\test.txt");
if(!ofile)
{
cout<<"test.txt can’t open"<<end1;
return 0;
}
ofile<<"This book is C++"<<" "<<12345<<end1;
ofile.close();
ifstream ifile("D:\\test.txt");
if ( ! ifile)
{
cout<<"test.txt can’t open"<<end1;
return 0;
}
char str[80];
ifile>>str;
ifile.close();
cout<<str<<end1;
return 1;
}
程序执行后的输出结果是【 】。
选项
答案
This
解析
本题考核文件的I/O操作。程序中的初始化值不能被修改,所以程序最后输出n=10。另外程序中定义了ofstream类的对象ofile和ifstream类的对象 ifile,然后利用对象ofile在文件test.txt中写入“This book is C++12345”。最后利用对象ifile打开文件,将其中的数据输入到变量str中,由于读时遇到空F时就终止,所以str中存放的字符串为“This”。
转载请注明原文地址:https://kaotiyun.com/show/eGjp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序#includemain(){inta=0,b=0;/*给a赋值a=10;b=20:给b赋值*/printf("a+b=%d\n",a+b);/*输出计算结果*/}程序运行后的输出结果是
算法的有穷性是指
有以下程序#includestructSTU{charname[9];charsex;intscore[2];};voidf(structSTUa[]){structSTUb={"zhao",’m’
以下叙述中错误的是
有以下程序main(){inta=1,b=3,c=5;int*p1=&a,*p2=&b,*p=&c;*p=*p1*(*p2);printf("%d\n",c);}执行后的输出结果是
在黑盒测试方法中,设计测试用例的根据是
下面选项中的程序段,没有编译错误的是()。
若实体A和B是一对多的联系,实体B和C是一对一的联系,则实体A和C的联系是
在软件开发中,需求分析阶段产生的主要文档是()。
能从任意一个结点开始没有重复地扫描到所有结点的数据结构是
随机试题
确定中国共产党是整个国家的领导核心是_____。
产妇,27岁,正常阴道分娩,护士给护生讲解正常的脐带结构是
肺换气的驱动力是
(2009年)图5—32所示外伸梁,A截面的剪力为()。
某承包企业承包一工程,计划砌砖工程量1200立方米,按预算定额规定,每立方米耗用空心砖510块,每块空心砖计划价格为0.12元;而实际砌砖工程量却达1500立方米,每立方米实耗空心砖500块,每块空心砖实际购入价为0.18元。利用差额计算法分析材料单价变动
我国提出“三步走”战略,全面建设小康社会,都是以发展经济为中心。发展经济的根本目的是()。
American
A、Althoughthefutureofopticalcomputingisimpressive,itsapplicationsaretoolimitedinscopetojustifymuchoptimism.B、
A、Thegoodviewsofthewholecity.B、Thelowcostsandhighspeed.C、Beingconfinedbyschedules.D、Enoughspaceandgoodcondi
Morethanfortythousandreaderstolduswhattheylookedforinclosefriendships,whattheyexpected【C1】______friends,whatt
最新回复
(
0
)