(一). 下載Vscode
(1). 打開Ubuntu軟件

(2). 搜索Vscode,下載並運行.


(二). 安裝C++
(1). 看到右邊的列表,點擊最下面的

(2). 然后我們搜索和下載 C++ 還有 C++ Intellisense(自動補全)

(三). 配置
(1). 我們回到歡迎界面,然后選擇一個目錄(Open folder)

(2). 我們創建一個cpp文件,並且命名為001.cpp

(3). 按下F5,然后選擇C++

(4). 這個時候會彈出launch.json

(5). 我們修改這一句
"program": "enter program name, for example ${workspaceFolder}/a.out",
去掉
enter program name, for example
(6)把launch.json關閉,我們回到001.cpp.
(7) 我們按下Ctrl + Shift + B ,然后會彈出,然后我們往下點,最后點Other



(8) 然后在彈出的tasks.json中,我們修改command項.

"command": "echo Hello"
修改為:
"command": "g++ -g -o a.out ${file}"
(9) 然后我們就可以關閉 返回001.cpp了。
(10) 我們按下 Ctrl + Shift + B 編譯文件 然后再按下F5運行程序.

最后附上完好的
launch.json
{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/a.out", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
tasks.json
{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "2.0.0", "tasks": [ { "label": "echo", "type": "shell", "command": "g++ -g -o a.out ${file}", "group": { "kind": "build", "isDefault": true } } ] }
