無需安裝龐大 IDE,僅需記事本與命令列工具即可完成 C/C++ 程式的編寫、編譯與執行。本文示範兩種主流 Windows 編譯器工具鏈:MinGW (GCC) 與 Microsoft Visual C++ (MSVC)。
1.c#include <stdio.h>
int main() {
printf("Hello, Command Line World!\\n");
return 0;
}
bin 資料夾,執行 mingwvars.bat 設定環境變數(或直接將 MinGW/bin 加入系統 PATH)cd /d %USERPROFILE%\Desktopgcc 1.c -o 1.exe1.exe 或 ./1.execl 1.c (產生 1.exe)1.exe-Wall -O2 (GCC) / /W4 /O2 (MSVC) 啟用警告與優化-g (GCC) / /Zi (MSVC)-std=c++17 (GCC) / /std:c++17 (MSVC)chcp 65001 切換代碼頁MinGW 適合跨平台開發、開源專案、GCC 生態系;MSVC 適合 Windows 原生開發、效能關鍵應用、Visual Studio 整合除錯。雙工具鏈並存可驗證程式碼可攜性。