一.问题描述
使用I/O流以文本方式打开上题建立的文件test1.txt,在次此文件后面添加字符“已成功添加字符!”,然后读出整个文件的内容显示出来,看看是否正确。
二.设计思路
三.流程图
四.伪代码
1
五.代码实现
1#include<fstream>
#include<iostream>
using namespace std;
int main() {
ofstream file1("text.txt", ios::app);
file1 << "Success to add character!";
char ch;
ifstream file2("text.txt");
while (file2.get(ch)) {
cout << ch;
}
file2.close();
return 0;
}
标签:文件,file1,txt,21.3,每日,打卡,include From: https://www.cnblogs.com/leapssisbird/p/17392525.html