如何用純 css 實現頁面滾動停靠效果
阿新 • • 發佈:2022-03-17
VSCode配置C/C++環境
一、MinGW
1、下載MinGW
MinGW-w64 - for 32 and 64 bit Windows - Browse /mingw-w64/mingw-w64-release at SourceForge.net
2、配置MinGW
進入系統環境變數:
將MinGW的bin目錄寫進path,我的MinGW目錄為:D:\Environments\mingw64\bin
3、檢查配置
進入cmd,輸入gcc:
配置成功。
二、VSCode
1、下載外掛
下載C/C++外掛
在一個空資料夾(英文)下新建一個main.cpp,編寫一個簡單的程式:
#include <iostream> using namespace std; void swap(int &a, int &b); int main(int argc, char *argv[]) { int a{1}; int b{3}; cout << "實現兩個數字交換" << endl; cout << "交換前a = " << a << ",b = " << b << endl; swap(a,b); cout << "交換後a = " << a << ",b = " << b << endl; return 0; } void swap(int &a, int &b) { int temp; temp = a; a = b; b = temp; }
2、配置方法一
c_cpp_properties.json檔案
- 按快捷鍵Ctrl+Shift+P調出命令面板,輸入C/C++,選擇“Edit Configurations(UI)”進入配置
- 然後就會自動生成.vscoe資料夾和c_cpp_properties.json檔案
{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "compilerPath": "D:\\Environments\\mingw64\\bin\\gcc.exe", "cStandard": "gnu17", "cppStandard": "gnu++14", "intelliSenseMode": "windows-gcc-x64" } ], "version": 4 }
tasks.json檔案
-
建立此檔案來告訴VS Code如何構建(編譯)程式。該任務將呼叫g++編譯器基於原始碼建立可執行檔案。
-
按快捷鍵Ctrl+Shift+P調出命令面板,輸入tasks,選擇Tasks:Configure Default Build Task
-
再選擇 C/C++: g++.exe build active file
-
此時就會生成一個tasks.json檔案
{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "compile", // 任務名稱,與launch.json的preLaunchTask相對應 "command": "D:\\Environments\\mingw64\\bin\\g++.exe", // 編譯器的路徑 // 編譯c++檔案使用g++.exe,c檔案使用gcc.exe,此處編譯c++檔案 "args": [ "-g", "${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "D:\\Environments\\mingw64\\bin" }, "problemMatcher": [ "$gcc" ], "group": "build" } ], "presentation": { "panel": "new", //這裡shared表示共享,改成new之後每個程序建立新的埠 } }
launch.json檔案
- 這個檔案主要用來配置除錯的相關資訊
- 點選選單欄的除錯
- 選擇建立launch.json檔案
- 此時就會產生launch.json的檔案
按如下程式碼配置即可:
{
"version": "0.2.0",
"configurations": [
{
"name": "g(gdb) Launch", // 配置名稱,將會在啟動配置的下拉選單中顯示
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false, //修改此項,讓其彈出終端
"internalConsoleOptions": "neverOpen", // 如果不設為neverOpen,除錯時會跳到“除錯控制檯”選項卡
"MIMode": "gdb",
"miDebuggerPath": "D:\\Environments\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "compile" //修改此項
// 除錯會話開始前執行的任務,一般為編譯程式。與tasks.json的label相對應
}
]
}
測試
斷點,按F5測試:
配置成功。
3、方法二
下載外掛
- C/C++ Project Generator
- CMake
- CMake Tools
建立專案
新建一個project資料夾(自己取名),用vscode開啟,按快捷鍵Ctrl+Shift+P調出命令面板,輸入Create C++ project(建立C++專案)或者輸入Create C project(建立C專案)。
自動建立和配置專案。
三、外掛推薦
- 翻譯(英漢詞典)
- Draw.io Integration
- Material Icon Theme
- Noctis
- Chinese (Simplified) (簡體中文) Language Pack for Visual Studio Code