C++句柄无效?
  • 板块灌水区
  • 楼主うっせぇわ
  • 当前回复5
  • 已保存回复5
  • 发布时间2021/7/11 11:58
  • 上次更新2023/11/4 15:06:01
查看原帖
C++句柄无效?
506475
うっせぇわ楼主2021/7/11 11:58

自己写了个程序:

#include <iostream>
#include <windows.h>
#include <fstream>
#include <cstring>
#include <string>
using namespace std;
string a[1001],b[1001];
int main(){
	freopen("1.txt","r",stdin);
	cout<<"正在读取文档1的内容……\n";
	for(int i=1;i<=78;i++){
		getline(cin,a[i]);
		//cout<<a[i]<<endl;
	}
	system("cls");
	cout<<"正在关闭文档……\n";
	fclose(stdin);
	system("cls");
	freopen("2.txt","r",stdin);
	cout<<"正在读取文档2的内容中……\n";
	for(int i=1;i<=150;i++){
		getline(cin,b[i]);
	}
	system("cls");
	cout<<"正在关闭文档……\n";
	fclose(stdin);
	system("cls");
	cout<<"正在组合文档……\n";
	freopen("3.txt","w",stdout);
	for(int i=1;i<=150;i++){
		cout<<a[i]<<" // ";
		cout<<b[i]<<endl;
	}
	system("cls");
	fclose(stdout);
	cout<<"正在关闭文档……\n";
	system("cls");
	cout<<"项目完成!\n";
	//*/
	return 0;
}

运行后:

大家可以帮忙吗?万分感谢。

2021/7/11 11:58
加载中...