lkk9898969
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.

      Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

      Explore these features while you wait
      Complete general settings
      Bookmark and like published notes
      Write a few more notes
      Complete general settings
      Write a few more notes
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # (新手向)使用VSCode撰寫、編譯並Debug(偵錯)C/C++程式碼 (Windows) ###### *注意時效性(本文撰寫於 2025/4)* 這篇文章是專門for C語言入門新手,或者是在被學校的程式語言用 Dev-C++ 荼毒過後的學生,想轉戰使用美觀、方便的VSCode寫C語言所做的教學。 當然我知道,有些人可能有一些奇怪的開發環境癖好(例如我),所以環境先講清楚,不喜歡直接上一頁避免浪費時間。 本文會使用Msys2安裝Clang Compiler,並且使用LLDB進行Debug。 另外,設定完成後,只會編譯單一檔案,不適用多檔編譯。 請注意,編譯環境for C (最後一節會教學C/C++編譯),作業系統使用Windows 10,理論上來說Windows 11應該不會有差別。 # 教學開始 ## 1. 安裝Msys2 首先請至[MSYS2](https://www.msys2.org/)官網下載安裝檔 ![](https://hackmd.io/_uploads/ByHXVEBRkl.png) > 紅框框起來的地方點下去就會直接下載 安裝過程我只提一點:安裝位置請自行抉擇,通常是如下圖預設C:\msys64 但是如果各位有需求需要更改安裝位置可隨意更改(最常見的理由 C槽不夠大,根據教學設定完後會占用2 GB),惟後面教學遇到C:\msys64的部分請修改為各位更改後的安裝路徑。 ![](https://hackmd.io/_uploads/HJ_yrVSCke.png) > 有需要自行將C:\msys64改掉,請注意後面步驟有遇到也要一起改 之後就是下一步點到底,等待安裝完畢。 安裝完畢之後會直接跳出一個終端機,先關閉他。 之後於左下角搜尋Msys2,打開Msys2的終端機 ![image](https://hackmd.io/_uploads/SJMbr4BCkg.png) > 於搜尋欄內搜尋msys2 打開後輸入 pacman -Syu ```bash pacman -Syu ``` ![image](https://hackmd.io/_uploads/BySVBESAyl.png) > 這行指令的作用是更新Msys2及套件 跑一下子之後會如下圖一樣卡住,直接壓Enter或者輸入y之後壓Enter都可以。 ![image](https://hackmd.io/_uploads/r1OSH4HCkg.png) > 個人是直接壓Enter,我懶 之後再跑一陣子又會卡住,直接壓Enter,應該會關閉終端機。 ![image](https://hackmd.io/_uploads/SyywBNB0Je.png) > 最後一行的意思就是說完成更新需要關閉終端機 之後重新開啟終端機,輸入 pacman -S mingw-w64-clang-x86_64-clang ```bash pacman -S mingw-w64-clang-x86_64-clang ``` ![image](https://hackmd.io/_uploads/S1gtB4rRyx.png) > 安裝Clang Compiler 會詢問你要不要安裝,一樣直接壓Enter ![image](https://hackmd.io/_uploads/rk3tB4B0Je.png) > 安裝Clang Compiler時會安裝的依賴套件列表以及Clang本身 那這段安裝時間需要一段時間,取決於網路給不給面子,可以先去泡杯咖啡來喝或者滑個手機。 跑完之後就可以直接把Msys2終端機關掉了。 ## 2. 更改PATH環境變數 按下Win+R輸入"rundll32.exe" sysdm.cpl,EditEnvironmentVariables,開啟環境變數設定。如果沒有出現,請將每個視窗一個一個縮小,應該是被其他視窗擋住了。 ```bash "rundll32.exe" sysdm.cpl,EditEnvironmentVariables ``` ![image](https://hackmd.io/_uploads/SJSGLVB01l.png) > 右鍵點擊Windows按鈕選"執行"也可以叫出來 選擇Path,按編輯。 ![image](https://hackmd.io/_uploads/By1rIVH0Jx.png) > 上面跟下面的Path都可以 選擇瀏覽,之後選到C:\msys64\clang64\bin,點確定 ![image](https://hackmd.io/_uploads/r1AS8EHAye.png) > 前面有改路徑的同學請記得自己換路徑! 之後就是確定三連即可。如果你的VSCode開著,請將VSCode完全關閉後重開,VSCode才會套用新的環境變數。 *上面這邊是設定路徑的環境變數,方便之後VSCode執行指令。* > 上面這段主要是在安裝Compiler,VSCode本身只是編輯器,並不具備編譯C語言程式的能力;而我使用Msys2安裝的原因是:方便。大部分的人可能會覺得在那邊打指令打來打去還沒我直接google的快哪裡方便? 只能說以後如果各位要裝一堆雜七雜八且都是for 類Unix系統使用的套件時就會明白Msys2的好了。還有,一鍵更新是真的爽。 ## 3. 安裝 VSCode 我希望這個章節可以不用教,畢竟VSCode就是左鍵點到底,但是安裝時有一些小設定我覺得很重要的因此稍微提一下,如果各位已經裝完了就可以跳過了。 一樣先到[VSCode](https://medium.com/r/?url=https%3A%2F%2Fcode.visualstudio.com%2Fdownload)官網下載安裝 ![image](https://hackmd.io/_uploads/rye2UNB01x.png) > 一樣紅框框起來的地方,點ㄊ下載 安裝到第三頁的時候注意一下,我建議這裡的選項全勾起來。 ![image](https://hackmd.io/_uploads/rymaLNB0ye.png) ## 4. 安裝VSCode的延伸模組 安裝完成之後打開VSCode,我們需要安裝一些延伸模組來幫助我們使用VSCode上使用的更順利。 首先點選左邊的延伸模組(Extension) ![image](https://hackmd.io/_uploads/BJYR8EH01x.png) > 一樣點紅框框 在上面的Search欄位打Chinese,看到那個中文(繁體)的Install按鈕,點他。 ![image](https://hackmd.io/_uploads/rJ91wNBR1x.png) > 當然你要裝簡體的或者直接不裝用英文我也不反對 好了之後右下角會問你要不要切換語言,點擊按鈕,VSCode應該會自動關閉後重啟,並且語言變為中文。 ![image](https://hackmd.io/_uploads/H11-vNSRkg.png) > 點擊Change Language and Restart 重新啟動完成之後,點擊左邊的延伸模組,接下來安裝C語言的延伸模組,讓VSCode支持C語言的語法。 ![image](https://hackmd.io/_uploads/ry7GwEHRkl.png) > 搜尋C,對C/C++延伸模組點擊安裝 再次搜尋,這次搜尋CodeLLDB,安裝Debugger。 ![image](https://hackmd.io/_uploads/S1eQwErR1g.png) 這個Debugger安裝需要一點時間(取決於網路速度)。 到這邊VSCode延伸模組安裝就差不多完成了,接下來便是教學如何用VSCode寫C語言以及編譯、Debug。 ## 5. 準備Workspace 要使用VSCode寫程式,我這裡強烈建議,請把每個語言的資料夾都分開,並且一定要開啟一個資料夾作為Workspace,方便管理環境。 首先在桌面(或者你喜歡的任何地方)創建一個資料夾,這個資料夾專門放置C語言檔案。範例如下,我在桌面創建一個資料夾"C"。名稱注意一下,請盡量不要是中文且不要有空白(空白可用底線(_)取代)。 ![image](https://hackmd.io/_uploads/S1wHwNr0kx.png) > 位置與名字都隨意,但請盡量不要是中文且不要有空白。 點開資料夾之後,在空白處點右鍵,會看到一個選項"以Code開啟",點他。 ![image](https://hackmd.io/_uploads/SyUDv4rRye.png) > 還記得我們安裝VSCode時勾選的選項嗎? 就是在這裡派上用場了,非常好用! 打開VSCode之後我們就會在這個C資料夾裡了。 ![image](https://hackmd.io/_uploads/r1lKwESAkl.png) > 檔案總管下面的C 就是範例中的C資料夾了 滑鼠移到檔案總管上,可看到資料夾上有浮現選項,左邊為新增檔案,右邊為新增資料夾。 ![image](https://hackmd.io/_uploads/SynFvVrRkl.png) 點選新增檔案,並且命名檔案。任意名稱,盡量不要是中文且不要有空白,但是後綴必須是.c ![image](https://hackmd.io/_uploads/ryu9wVBRyx.png) > 這裡命名為lkk1.c,記得一定要.c結尾,VSCode才會識別為C語言檔案 之後我們就可以開始編寫程式了。以下示範為一個簡單的Helloworld程式。 ![image](https://hackmd.io/_uploads/HJLsD4rCye.png) > 各位自己打一遍,就會知道VSCode的方便與強大之處! 好,可是這個時候要怎麼運行? VSCode這個時候還不知道如何編譯與運行你的檔案,因此我們需要寫設定來讓VSCode自動地幫我們編譯與運行。 ## 6. 設定VSCode的編譯與運行 接下來我們要設定VSCode,幫我們運行指令。 首先按下F1,輸入con,找到 工作: 設定工作,來設定編譯工作。 ![image](https://hackmd.io/_uploads/B1bav4BCJg.png) ### A. 如果你前面的Path環境變數有設定正確,沒有意外的話會跳出clang的編譯工作,直接點選他。 *(沒跳出請跳到[B.](#B-如果你的並沒有跳出clang編譯工作選項,選擇-從範本建立tasksjson檔案,) )* ![image](https://hackmd.io/_uploads/BJQJd4S0kg.png) ![image](https://hackmd.io/_uploads/Hy2yd4HCJl.png) > 如果要知道tasks.json的內容意義,請自行參閱VSCode官方文檔。 這邊請將label的內容改為build,方便之後的設定。 ![image](https://hackmd.io/_uploads/B1hxuNS0ye.png) > 反白處 ### B. 如果你的並沒有跳出clang編譯工作選項,選擇 從範本建立tasks.json檔案, ![image](https://hackmd.io/_uploads/r1H7uVHRJe.png) 之後選擇Others。 ![image](https://hackmd.io/_uploads/ry37dNB0ke.png) 貼上以下內容於"tasks":[ ] 的[ ]內即可。 ```json { "label": "build", "type": "shell", "command": "clang", "args": [ "-g", "${file}", "-o", "${workspaceFolder}/${fileBasenameNoExtension}.exe" ], } ``` 結果如下圖。 ![image](https://hackmd.io/_uploads/ByeIdNBA1e.png) 到這邊,編譯工作已經完成,但VSCode到這邊也只會幫你編譯出可執行檔, 此時VSCode只能運行,還不能Debug,因此我們需要再設定Debug設定。 點選左邊的Debug選單,並按下 建立launch.json檔案。 ![image](https://hackmd.io/_uploads/ryXw_VH0kg.png) > 建立Debug設定檔 選擇LLDB。 ![image](https://hackmd.io/_uploads/H1WOuVBC1g.png) > 不要選到上面兩個選項喔! 點下去之後會跳出一個選單,這邊請直接按ESC就好。 ![image](https://hackmd.io/_uploads/B16u_Vr0ye.png) > 如果有跳出這個選單直接按ESC就好 接下來要修改一下這個launch.json檔案。 請將這個<executable file\>換成 {fileBasenameNoExtension}.exe 。 ```json ${fileBasenameNoExtension}.exe ``` ![image](https://hackmd.io/_uploads/SyxTdVSR1e.png) > 修改前,要修改的地方我有幫你反白 ![image](https://hackmd.io/_uploads/r1iRONS0kx.png) > 修改後,如圖上所示。 之後還要新增一個選項preLaunchTask。 ```json "preLaunchTask": "build" ``` ![image](https://hackmd.io/_uploads/SJaUYVBCyx.png) 或者你直接copy以下的文字到launch.json檔案也可以,只要長得跟上圖一樣就行。 ```json { "type": "lldb", "request": "launch", "name": "Debug", "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe", "args": [], "cwd": "${workspaceFolder}", "preLaunchTask": "build" } ``` 好了到這邊我們就結束VSCode的設定了,可以開始嘗試編譯並Debug C語言檔案了。 ## 7. 編譯並運行C語言程式 點選左邊的檔案總管,回到我們的C語言檔案。 ![image](https://hackmd.io/_uploads/S1F5FEHRyg.png) 之後直接按下F5,就可以執行了。 ![image](https://hackmd.io/_uploads/ByEjtEBRkx.png) > 等待一段時間後的執行成果 嗯? 阿我們的Hello world!怎麼不見了? 其實是被VSCode給偷偷隱藏起來了! 點選下面的終端機,就可以看到執行結果了。 ![image](https://hackmd.io/_uploads/Sy73Y4SR1x.png) > 到終端機這裡就可以看到我們的Hello World! *(可選)* 如果不喜歡VSCode內建的終端機,可以在launch.json再新增一個選項,使用外部的終端機(外部的cmd、powershell等)。 ```json "console": "externalTerminal" ``` ![image](https://hackmd.io/_uploads/r1r-qNB0ye.png) 好的,到這邊就已經可以開始寫你自己的C語言程式了! 這邊有幾點注意事項提醒各位。 #### A.右上角也有一個選項是 偵錯C/C++檔案 ,我們這邊並沒有設定這邊的參數,因此會無法執行,若要用這邊的選項請自行找網路上的資源來設定。 #### B.按下F5檔案時,當前的視窗開啟的檔案必須要是你要編譯的.c檔!(也就是你畫面上的文字編輯器的內容要是.c檔的內容)  VSCode會根據你視窗開啟的檔案自動識別要編譯的檔案名字,並根據名字產生執行檔並運行偵錯。 編譯環境建置教學到此結束,下面都是額外教學不必要做。A.是在介紹VSCode Debug介面以及功能,如果各位以前沒有使用過Debug建議看一下,可以讓各位以後Debug的時候更有效率。 # 額外介紹/教學 ## A. VSCode Debug功能簡單介紹 我們寫一個包含變數與迴圈的程式,來介紹Debug功能。 ![image](https://hackmd.io/_uploads/Sy8V54rC1l.png) > 範例程式 於行數的左邊,滑鼠滑上去時可以看到紅色的點,這個點稱為"中斷點",意思是當程式運行到有紅點的那行便會自動暫停。暫停時,VSCode會秀出各個變數的內容! ![image](https://hackmd.io/_uploads/Bk9Sq4HAkl.png) ![image](https://hackmd.io/_uploads/HJCHcNHCJl.png) > 程式暫停時的樣子 於左邊的介面中,"變數"會顯示出Local(局域)變數與其他的全域和Static變數,而紅框中是我滑鼠移到一個變數上,VSCode會有Hover顯示該變數的內容。 中斷點可以自行增減,在程式執行時與暫停時皆可設置,因此可以設置多個中斷點方便觀察程式運行的過程與結果。 而上面的選單也需要介紹,也是很重要的功能。最左邊的叫做"繼續",意思就是讓程式再繼續執行,直到遇到下一個中斷點。例如我將中斷點從第8行改到第13行並按下"繼續",程式就會一直執行直到第13行又再次暫停。 ![image](https://hackmd.io/_uploads/S1NvqVrR1x.png) > 取消第8行的中斷點,並在第13行增設中斷點 ![image](https://hackmd.io/_uploads/HJkcc4H01l.png) > 按下"繼續"後程式停在第13行,可看到此時\*並沒有印出 接下來則是右邊的"不進入函式"、"逐步執行"與"跳離函式",要解釋這三個的差異需先撰寫一個函式方便講解。我這邊撰寫另外一個範例程式講解。 ![image](https://hackmd.io/_uploads/rkcjc4rCke.png) > 新的範例程式,含有函式,不會函式請查C語言教學,這裡不贅述 我們將中斷點設置在第12行,並按下"逐步執行",看看會發生什麼事? ![image](https://hackmd.io/_uploads/BJV25VSRJl.png) > 程式於12行暫停,還未按下"逐步執行" ![image](https://hackmd.io/_uploads/SJ635EH01x.png) > 按下逐步執行後,可看到程式跑到了函式內部! 逐步執行,顧名思義就是一步一步往下做,包含函數的內部也會一步一步往下做,當你要查看函數內部的運行狀況(例如傳入函數的數值為何、函數內的執行等),就非常有用! 那我們接下來看"跳離函式"。簡而言之,跳離函式便是讓程式一直執行直到這個函式返回。**請注意,跳離函式的意思並不是直接讓函式在該行直接返回! 而是讓程式一直執行直到函式返回!** 這個在執行一個較大的函式時,若我們要查看的部分只在函式前面,而後面不care的時候,這個時候查看完直接按跳離函式就會非常方便。 ![image](https://hackmd.io/_uploads/SyRJi4HAJx.png) > 我們直接在第4行那邊按跳離函式 注意到上圖幾件事情:  #### 1. 我並沒有在12行按中斷點(我將第12行的中斷點取消了),然而在我按下跳離函式後,程式依然是停在第12行。 #### 2. 左邊的Local可看到return value,這邊可以直接讓各位看到函式返回值,相當方便! 最後便是"不進入函式",顧名思義便是直接跳過函式的內部步驟, 當我想focus在main的運行,而不想管函式細節時就會使用這個功能。**一樣請注意,不進入函式並不是跳過這個函式不執行了! 而是將這一行當成一個敘述,直接執行到下一行。** ![image](https://hackmd.io/_uploads/r1yUjVBRkx.png) > 於第12行按下中斷點使程式停在12行 ![image](https://hackmd.io/_uploads/ByFLo4SAJg.png) > 程式會直接往下跳下一行。 一樣可以注意到幾件事情:  #### 1. 直接跳到下一行,並沒有在函式內部暫停。 #### 2. 左邊變數的監看可以看到tmp 的6有稍微反白,當你每運行 1行程式,若變數有更動,則有變動的變數VSCode會幫你反白,方便Debug。 ## B. 自動排版 剛開始寫程式語言時,可能對於排版無感,例如下面這種。但是,一個良好的排版對於程式碼閱讀是很重要的! 但是你說我手動排版很麻煩啊? 那怎辦? 其實VSCode可以自動幫你排版! ![image](https://hackmd.io/_uploads/SkiKjNB0Jx.png) > 這種排版真的會讓人看到非常抓狂 那要如何設定呢? 請按下F1,輸入format,選擇 文件格式化方式... ![image](https://hackmd.io/_uploads/ryncsNSCkl.png) 選擇 設定預設格式器 ![image](https://hackmd.io/_uploads/BJXjjVHRJe.png) > 選擇C/C++則是會直接幫你排版 選擇 C/C++ ![image](https://hackmd.io/_uploads/rJl3jES01l.png) > 按Enter選擇格式器 之後點左下角的齒輪,點設定 ![image](https://hackmd.io/_uploads/Sy62j4SRJe.png) 在設定上搜尋format,將 Format On Save 打勾 ![image](https://hackmd.io/_uploads/rkvTjEBAJe.png) 之後回到我們的.c檔,按下Ctrl + S 儲存檔案,此時VSCode就會自動幫我們排版排好了! ![image](https://hackmd.io/_uploads/S11RsEBA1x.png) > 簡單、省時、美觀又方便 ## C. 使用Clangd提示 在本篇 4.安裝延伸模組 時,我們使用C/C\++延伸模組內建的提示,來幫助我們提示函式的名稱。然而本人認為C/C\++內建的提示其實挺破爛的,我自己是使用Clangd提示,會更方便一點。 ![image](https://hackmd.io/_uploads/ryiz2VS0kx.png) > 新手最常見的錯誤 : scanf傳參忘記加&,clangd會直接幫你標示出來! 安裝也很簡單,首先一樣左邊延伸模組Clangd,安裝。 ![image](https://hackmd.io/_uploads/r1YX3VHAyl.png) 安裝完之後右下角會跳出兩個選項,按 Disable IntelliSense。 **請不要按Install,會出事。** ![image](https://hackmd.io/_uploads/BJONh4B0ke.png) > 如果不小心點到Install請記得取消 之後則是下載Clangd,Clangd也可以在Msys2上下載到,打開Msys2終端機,輸入pacman -S mingw-w64-clang-x86_64-clang-tools-extra ```bash pacman -S mingw-w64-clang-x86_64-clang-tools-extra ``` ![image](https://hackmd.io/_uploads/H1NU34SRJe.png) > 用Msys2安裝clangd 之後重開VSCode就可以了。 另外,這個時候自動排版的設定會跑掉,請回到[B. 自動排版](#B-自動排版)重新設定一次,但要選擇Clangd作為格式器。 ## D. 根據後綴自動判別C/C++檔案並編譯 我們上面所用的設定是for C語言的,這個時候如果你用.cpp檔案寫一個C\++程式會發現編譯不讓你過,因此要改用C\++的編譯器。 ![image](https://hackmd.io/_uploads/rJaP3ESAJe.png) > C++的Hello World程式,編譯報錯了 請在左邊的延伸模組尋找Command Variable,並安裝 ![image](https://hackmd.io/_uploads/HJ3dhESAJx.png) > 安裝Command Variable延伸模組 之後請找到tasks.json,在檔案總管下的.vscode資料夾內。 ![image](https://hackmd.io/_uploads/BkjK2ES0kx.png) > .vsocde資料夾內含VSCode的設定檔案 請將tasks.json的內容與下圖紅框的內容進行比對,並修改成與圖內一致。 ```json "type": "shell" ``` ```json clang${input:pickExtension}.exe ``` ```json "inputs": [ { "id": "pickExtension", "type": "command", "command": "extension.commandvariable.file.fileAsKey", "args": { ".cpp": "++", ".c": "" } } ] ``` ![image](https://hackmd.io/_uploads/SyOq2ErCJx.png) 如果tasks.json是複製我文章上的內容,請將clang那行修改,並加上inputs那些內容即可。 ![image](https://hackmd.io/_uploads/By-x64H0yl.png) > 如果tasks.json是用複製的,結果如圖 修改好之後回到我們的C++檔案,按F5運行。 ![image](https://hackmd.io/_uploads/B1ebTNHR1x.png) > 修改好之後使用clang++編譯,運行成功 可以發現我們的C++程式可以正常的執行了。 ## E. 變更VSCode主題顏色 不習慣黑畫面? 想改成白畫面? 點選左下角設定->主題->色彩佈景主題 ![image](https://hackmd.io/_uploads/S1pjESS0Jx.png) 上面就會有很多選項給你選了。 ![image](https://hackmd.io/_uploads/HyZJHHBRJg.png) --- 好的,本篇教學就到此結束,本人第一次寫這種教學也是第一次用HackMD,若有問題歡迎留言詢問。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully