5 分鐘搞定 vscode 設(shè)置:文件輸入輸出
2023-01-23 20:43 作者:目標(biāo)力扣Knight | 我要投稿

# visual studio code 中如何以文件方式導(dǎo)入與導(dǎo)出?
## 代碼
```cpp
#include <iostream>
using namespace std;
int main(void) {
??// 重定向:參數(shù):文件名,讀寫模式文件類型
??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;
}
```
## 文件層級(jí)
```bash
PS D:\BaiduSyncdisk\test0121> tree /f
卷 新加卷 的文件夾 PATH 列表
卷序列號(hào)為 FABA-5422
D:.
│?helloworld.cpp
│?helloworld.exe
│?in.txt
│?out.txt
│
└─.vscode
????tasks.json
```
標(biāo)簽: