5 分钟搞定 vscode 设置:文件输入输出
2023-01-23 20:43 作者:目标力扣Knight | 我要投稿

# visual studio code 中如何以文件方式导入与导出?
## 代码
```cpp
#include <iostream>
using namespace std;
int main(void) {
// 重定向:参数:文件名,读写模式文件类型
freopen("in.txt", "rt", stdin);
freopen("out.txt", "wt", stdout);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cout << i << endl;
}
return 0;
}
```
## 文件层级
```bash
PS D:\BaiduSyncdisk\test0121> tree /f
卷 新加卷 的文件夹 PATH 列表
卷序列号为 FABA-5422
D:.
│ helloworld.cpp
│ helloworld.exe
│ in.txt
│ out.txt
│
└─.vscode
tasks.json
```