@[LZCR](/space/show?uid=114479) 3可能需要用高于OI的东西做……
然后1和2用`sscanf`函数qwq
by 花里心爱 @ 2019-01-16 20:21:05
@[LZCR](/space/show?uid=114479) 3 请自行ls...
1和2楼上正解。。当然也可以用char数组拼接做。。
by rEdWhitE_uMbrElla @ 2019-01-16 20:23:04
@[Irressey](/space/show?uid=79017) 谢谢指点,1操作我会做,我想了解一下2怎么做,3操作不着急用
by presucc @ 2019-01-16 20:23:29
@[SLF_LLL_SPFA](/space/show?uid=119553) 好吧……
by presucc @ 2019-01-16 20:24:51
@[LZCR](/space/show?uid=114479) 1和2:
```
#include<bits/stdc++.h>
using namespace std;
int main(){
char c[1000];
scanf("%s",c);
sprintf(c,"%s.txt",c);
ofstream fout(c);
fout<<"hello world";
}
```
by rEdWhitE_uMbrElla @ 2019-01-16 20:27:53
@[LZCR](/space/show?uid=114479) 刚才不小心说错了是`sprintf` qwq
然后我给个程序
```
#include <cstdio>
#include <cstring>
char s[105];
char fl[105];
int main() {
scanf("%s", s);
sprintf(fl, "%s.txt", s);
freopen(fl, "w", stdout);
printf("hello world;");
fclose(stdout);
return 0;
}
```
by 花里心爱 @ 2019-01-16 20:28:19
@[SLF_LLL_SPFA](/space/show?uid=119553)
@[Irressey](/space/show?uid=79017)
谢各路神犇
by presucc @ 2019-01-16 20:38:56
@[LZCR](/space/show?uid=114479) 突然发现3怎么写。。。
```
#include<bits/stdc++.h>
#define s sys##tem
using namespace std;
int main(){
char c[1000];
scanf("%s",c);
sprintf(c,"%s.txt",c);
freopen(c,"w",stdout);
printf("hello world\n");
s("ls -A && ls -A | wc -l");
}
```
by rEdWhitE_uMbrElla @ 2019-01-16 20:40:18
@[SLF_LLL_SPFA](/space/show?uid=119553) ls?
by presucc @ 2019-01-16 20:43:29
@[SLF_LLL_SPFA](/space/show?uid=119553) 提示ls命令不是内部或外部命令
by presucc @ 2019-01-16 20:44:47