壓縮包
通過網盤分享的文件:MinGW.zip
鏈接: https://pan.baidu.com/s/1QB-Zkuk2lCIZuVSHc-5T6A 提取碼: 2c2q
需要下載的插件
1.翻譯
找到VScode頁面,從上數第4個,點擊擴展(以下通此)
搜索---Chinese--點擊---安裝--ok
2.運行
第一個步驟同上
搜索--Code Runner and C/C++ Compile Run--點擊---安裝--ok
3.其他
C/C++?
C/C++ Extension Pack
C/C++ Themes
4.智能AI補全代碼
CodeGeeX:AI Coding Assistant
環境配置
1.環境變量
點擊win鍵--搜索環境變量--找到之后點擊進去--點擊右下角的環境變量--找到系統變量下面的path--新建(直接雙擊也行)--粘貼D:\MinGW\bin(根據自己的路徑進行粘貼)--不要點擊?,點擊所有的確定,少一個也不行
2.檢查是否配置完好
win + R? --- 輸入cmd,打開黑框
輸入gcc -v/gcc --version --有相應的版本信息提示就是成功了,就可接著往下配置了
配置文件
這些都是在.vscode下面的,不知道的自己搜索,查找資料
重點:路徑自己該改,應該能夠看懂的
1.c_cpp_properties.json
{"configurations": [{"name": "Win32","includePath": ["${workspaceFolder}/**"],"defines": ["_DEBUG","UNICODE","_UNICODE"],"compilerPath": "D:\\MinGW\\bin\\gcc.exe","cStandard": "c11","cppStandard": "gnu++14","intelliSenseMode": "windows-gcc-x86"}],"version": 4
}
2.launch.json
{"configurations": [{"name": "C/C++: gcc.exe 構建和調試活動文件","type": "cppdbg","request": "launch","program": "${fileDirname}\\${fileBasenameNoExtension}.exe","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "D:\\MinGW\\bin\\gdb.exe","setupCommands": [{"description": "為 gdb 啟用整齊打印","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "將反匯編風格設置為 Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}],"preLaunchTask": "C/C++: gcc.exe 生成活動文件"}],"version": "2.0.0"
}
3.settings.json
{"files.associations": {"*.sqlbook": "sql","*.ndjson": "jsonl","*.dbclient-js": "javascript","stdio.h": "c"}
}
4.tasks.json
{"tasks": [{"type": "cppbuild","label": "C/C++: gcc.exe 生成活動文件","command": "D:\\MinGW\\bin\\gcc.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "調試器生成的任務。"}],"version": "2.0.0"
}
代碼運行
1.書寫代碼
# include <stdio.h>
// std-->standard 標準庫,io-->input/output 輸入輸出,h-->header 頭文件int main(){// main函數是程序的入口,程序從這里開始執行,有且僅有一個printf("Hello World!\n");// printf是一個庫函數,用于輸出字符串return 0;// return 0;表示程序正常結束
}
2.運行
如果上面的插件都安裝完成了,就看運行,沒有全部安裝的話可能有的不能用
第一個,右鍵 -- Run Code(可以看見有快捷鍵)
第二個,右上角的三角符號(也有對應的快捷鍵)