一般的文件读写是这样的:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
freopen("xxx.in","r",stdin);
freopen("xxx.out","w",stdout);
fclose(stdin);
fclose(stdout);
return 0;
}
如果我想把上面的“xxx.in”换成一个字符串,会报错,如下:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s="xxx.in";
signed main(){
freopen(s,"r",stdin);
freopen("xxx.out","w",stdout);
fclose(stdin);
fclose(stdout);
return 0;
}
如果我想把这种写法变成合法的,应该怎么做?