玄关
  • 板块学术版
  • 楼主Max_LS
  • 当前回复0
  • 已保存回复1
  • 发布时间2024/7/15 11:37
  • 上次更新2024/7/15 13:42:55
查看原帖
玄关
1227116
Max_LS楼主2024/7/15 11:37

freopen的文件名怎么设置成变量,现在的情况就是输入了文件名就会崩

#include<bits/stdc++.h>
#include<conio.h>
using namespace std;
struct string_new{
	string s;
}str[1000];
int main(){
	int i;
	char* file_name;
	cin>>file_name;
	freopen(file_name,"w",stdout);
	for(i=0;;i++){
		getline(cin,str[i].s);
		int key=_getch();
		if (key==27) {
			break;
		}
		if(str[i].s=="\n"){
			continue;
		}
	}
	for(int j=0;j<i;j++){
		cout<<str[j].s;
		cout<<endl;
	}
	return 0;
}
2024/7/15 11:37
加载中...