# VS code 配置
# 1.下載並安裝 VS code
https://code.visualstudio.com/
# 2.安裝git
https://git-scm.com/
設為預設終端機


# 3.安裝MinGW-w64
https://www.mingw-w64.org/





下載完後雙擊解壓

會得到一個w64devkit資料夾

把他放到C:\下
加進環境變數



點一下Path讓他反白,然後按編輯


填入路徑


到了上一個面板也要按一次確定,修改才會生效

之後就可以自己用gcc或g++指令編譯了

範例程式 hello.c
```c
#include <stdio.h>
int g = 0;
int test_function_2(){
printf("In the test function 2\n");
g++;
}
int test_function_1(int *n){
printf("In the test function 1\n");
*n += 1;
int b = 0;
test_function_2();
}
int main(){
int a = 0;
a++;
printf("hello world\n");
test_function_1(&a);
return 0;
}
```
使用以下指令編譯
```bash
gcc -g -Wall hello.c
```
# 4.配置gdb
進入調試面板

新建一個設定文件

選擇 gdb

填入以下配置
```json
"configurations": [
{
"name": "GDB Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.exe", // 可執行文件路徑
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerPath": "C:/w64devkit/bin/gdb.exe", // GDB 的完整路徑
"externalConsole": true,
"stopAtEntry": true,
"args": [], // 程式執行時的參數
"setupCommands": [
{
"description": "啟用漂亮打印(pretty-printing)",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
}
]
```

之後側欄的調試介面應該會變這樣

然後按下這個符號就會開始

會出現這個面板可以控制gdb前進的方式

旁邊的面板可以觀察各種變化的訊息
