欢迎来到天天文库
浏览记录
ID:57410045
大小:90.50 KB
页数:4页
时间:2020-08-16
《C程序设计实验报告.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、C++语言程序设计实验报告基础题一实验任务:使用I/O流以文本方式建立一个文件test1.txt,写入字符“已成功写入文件!”,用其它字处理程序(例如windows的记事本程序Notepad)打开,看看是否正确写入。代码:#includevoidmain(){ofstreamfile("test.txt");file<<"已成功写入文件!";file.close();}结果:基础题二实验任务:使用I/O流以文本方式打开上一题建立的文件test1.txt,读出其内容显示出来,看看是否正确。代码:#include2、ream.h>voidmain(){charch;ifstreamfile1("test.txt");while(file1.get(ch))cout<voidmain(){ofstreamfile("test.txt",ios::app);file<<"已成功添加字符!";file.c3、lose();charch;ifstreamfile1("test.txt");while(file1.get(ch))cout<4、#includeclassdog{public:intweight;intage;dog(){}dog(intweight1,intage1){weight=weight1;age=age1;}~dog(){}};intmain(){dogdog1(5,10);dogdog2;ofstreamfout;ifstreamfint;fout.open("out.txt");fout<>dog2.wei5、ght>>dog2.age;cout<
2、ream.h>voidmain(){charch;ifstreamfile1("test.txt");while(file1.get(ch))cout<voidmain(){ofstreamfile("test.txt",ios::app);file<<"已成功添加字符!";file.c
3、lose();charch;ifstreamfile1("test.txt");while(file1.get(ch))cout<
4、#includeclassdog{public:intweight;intage;dog(){}dog(intweight1,intage1){weight=weight1;age=age1;}~dog(){}};intmain(){dogdog1(5,10);dogdog2;ofstreamfout;ifstreamfint;fout.open("out.txt");fout<>dog2.wei
5、ght>>dog2.age;cout<
此文档下载收益归作者所有