.deb
檔安裝,Redhat 系列則可以下載 .rpm
Ctrl + Shift + X
切換到插件視窗,搜尋 Chinese
,找到繁體中文的插件後點右下角的 Install,重開 VSCode 之後就會變成中文了
系統路徑 (PATH) 是相當重要的概念,以後會很常用
"C_Cpp.intelliSenseEngine": "Tag Parser"
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\Program Files (x86)\\CodeBlocks\\MinGW\\bin\\gcc.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\Program Files (x86)\\CodeBlocks\\MinGW\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
{
// 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": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files (x86)\\CodeBlocks\\MinGW\\bin\\gdb32.exe",
"setupCommands": [
{
"description": "啟用 gdb 的美化顯示",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
gcc
指令編譯程式碼的格式如下:
$ gcc [原始碼檔名] -o [執行檔檔名]
-o [執行檔檔名]
則預設會是 a.exe
main.exe
或者 main
.\main.exe
或 ./main.exe
gcc main.c -o main.exe & main.exe
gcc main.c -o main.exe; ./main.exe
gcc main.c & a
main.exe > out.txt
把程式輸出導向到 out.txt
main.exe < inn.txt
將 inn.txt
輸入到程式裡面main.exe < inn.txt > out.txt
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 0; i < 10; i++)
sum += i;
printf("Result: %d\n", sum);
return 0;
}
#include <stdio.h>
#include <math.h>
int main() {
for (int i = 0; i < 10; i++)
printf("sqrt(%d) = %.4lf\n", i, sqrt(i));
return 0;
}
$ sudo apt install gcc g++ gdb