主要流程
- 一、下載并安裝VScode
- 二、下載MinGw
- 配置環境變數
- 使用.c檔案配置C
- 運行程式
- 參考鏈接
一、下載并安裝VScode
VScode下載鏈接
安裝下載步驟下載,然后按照傻瓜式安裝就行



二、下載MinGw
MinGw下載鏈接
進去后往下翻找到 x86_64-posix-seh 點擊下載

安裝并解壓該檔案
記住你的解壓路徑,環境配置的時候需要用上

配置環境變數
此電腦單擊右鍵屬性
第五步新建,然后把解壓好的MinGw路徑放到如圖所示
路徑要到bin目錄下才行,然后依次點擊確定

驗證一下是否成功
Win+r,輸入cmd,再輸入gcc -v
圖為配置成功,否則環境變數配置失敗

使用.c檔案配置C
-
安裝Chinese中文語言包
打開vscode,安裝中文插件,安裝好了后重新啟動軟體
因為我已經安裝了,所以是中文

- 安裝C/C++
同理安裝

- 新建一個檔案夾,并在檔案夾下新建一個檔案:hello.c
#include <stdio.h>
int main()
{
printf("hello world!\n");
getchar();
return 0;
}
- 按F5除錯,默認配置

修改launch.json檔案并保存
{
// 使用 IntelliSense 了解相關屬性,
// 懸停以查看現有屬性的描述,
// 欲了解更多資訊,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "E:\\MinGW\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0 (1)\\mingw64\\bin",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "E:\\MinGW\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0 (1)\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "為 gdb 啟用整齊列印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}
- 使用Shift+Ctrl+p,如圖所示操作



修改tasks.json檔案并保存
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "C/C++: gcc.exe build active file",
"type": "shell",
"command": "E:\\MinGW\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0 (1)\\mingw64\\bin\\gcc.exe",
"args": [
? "-g",
? "${file}",
? "-o",
? "${fileDirname}\\${fileBasenameNoExtension}.exe"
? ],
? "options": {
? "cwd": "E:\\MinGW\\x86_64-8.1.0-release-posix-seh-rt_v6-rev0 (1)\\mingw64\\bin"
? },
? "problemMatcher": [
? "$gcc"]
}
]
}
運行程式
按F5運行程式

參考鏈接
官方檔案 參考配置
https://blog.csdn.net/qq_45236472/article/details/107352567
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/236650.html
標籤:區塊鏈
