一个fstream的问题,求问
  • 板块灌水区
  • 楼主dacapo791
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/8/14 14:44
  • 上次更新2024/8/14 16:11:11
查看原帖
一个fstream的问题,求问
1383923
dacapo791楼主2024/8/14 14:44

代码如下,但是控制台和test2.txt都输出了"testt"

#include<fstream>
#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
	ifstream a;
	ofstream b;
	char x;
	b.open("test1.txt");
	b<<"test";
	b.close();
	b.open("test2.txt");
	a.open("test1.txt");
	while(!a.eof()){
		a>>x;
		cout<<x;
		b<<x;
	}
	system("pause");
	return 0;
}
2024/8/14 14:44
加载中...