{"id":76268,"date":"2026-02-22T02:41:18","date_gmt":"2026-02-21T18:41:18","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/76268.html"},"modified":"2026-02-22T02:41:18","modified_gmt":"2026-02-21T18:41:18","slug":"vscode%e9%85%8d%e7%bd%aec-c%e7%8e%af%e5%a2%83%e5%85%a8%e6%94%bb%e7%95%a5","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/76268.html","title":{"rendered":"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565"},"content":{"rendered":"<p>\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684 VS Code \u914d\u7f6e C\/C&#043;&#043; \u5f00\u53d1\u73af\u5883\u7684\u6b65\u9aa4\u6307\u5357&#xff1a;<\/p>\n<h4>&#x1f4dd; \u4e00\u3001 \u5b89\u88c5\u5fc5\u8981\u7684\u7f16\u8bd1\u5de5\u5177\u94fe (\u4ee5 Windows \u4e3a\u4f8b&#xff0c;\u4f7f\u7528 MinGW)<\/h4>\n<li>\u4e0b\u8f7d MinGW-w64:\n<ul>\n<li>\u8bbf\u95ee MinGW-w64 \u5b98\u7f51 \u6216 SourceForge \u4e0b\u8f7d\u9875\u9762\u3002<\/li>\n<li>\u9009\u62e9\u6700\u65b0\u7248\u672c&#xff08;\u5982 x86_64-posix-seh&#xff09;\u7684\u5b89\u88c5\u7a0b\u5e8f\u4e0b\u8f7d\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u5b89\u88c5 MinGW-w64:\n<ul>\n<li>\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002<\/li>\n<li>\u5728\u5b89\u88c5\u9009\u9879\u4e2d\u9009\u62e9&#xff1a;\n<ul>\n<li>Version: \u6700\u65b0\u7a33\u5b9a\u7248 (\u5982 gcc 13.2.0)<\/li>\n<li>Architecture: x86_64<\/li>\n<li>Threads: posix<\/li>\n<li>Exception: seh<\/li>\n<li>Build revision: \u6700\u65b0<\/li>\n<\/ul>\n<\/li>\n<li>\u8bbe\u7f6e\u5b89\u88c5\u8def\u5f84 (\u5efa\u8bae\u907f\u514d\u4e2d\u6587\u548c\u7a7a\u683c\u8def\u5f84&#xff0c;\u5982 C:\\\\mingw64)\u3002<\/li>\n<li>\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u914d\u7f6e\u73af\u5883\u53d8\u91cf:\n<ul>\n<li>\u6253\u5f00 \u7cfb\u7edf\u5c5e\u6027 -&gt; \u9ad8\u7ea7 -&gt; \u73af\u5883\u53d8\u91cf\u3002<\/li>\n<li>\u5728 \u7cfb\u7edf\u53d8\u91cf \u4e2d\u627e\u5230 Path&#xff0c;\u70b9\u51fb \u7f16\u8f91\u3002<\/li>\n<li>\u70b9\u51fb \u65b0\u5efa&#xff0c;\u6dfb\u52a0\u4f60\u7684 MinGW bin \u76ee\u5f55\u8def\u5f84 (\u4f8b\u5982 C:\\\\mingw64\\\\bin)\u3002<\/li>\n<li>\u786e\u8ba4\u6240\u6709\u6253\u5f00\u7684\u7a97\u53e3\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u9a8c\u8bc1\u5b89\u88c5:\n<ul>\n<li>\u6253\u5f00\u65b0\u7684\u547d\u4ee4\u63d0\u793a\u7b26 (cmd) \u6216 PowerShell\u3002<\/li>\n<li>\u8f93\u5165 gcc &#8211;version \u5e76\u6309\u56de\u8f66\u3002<\/li>\n<li>\u5982\u679c\u770b\u5230\u7c7b\u4f3c gcc (MinGW-W64) 13.2.0 \u7684\u8f93\u51fa&#xff0c;\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>&#x1f9e9; \u4e8c\u3001 \u5b89\u88c5 VS Code<\/h4>\n<li>\u8bbf\u95ee VS Code \u5b98\u7f51\u3002<\/li>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u7528\u4e8e\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c (Windows, macOS, Linux)\u3002<\/li>\n<h4>\u2699 \u4e09\u3001 \u5b89\u88c5\u5fc5\u8981\u7684 VS Code \u6269\u5c55<\/h4>\n<li>\u6253\u5f00 VS Code\u3002<\/li>\n<li>\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u7684\u6269\u5c55\u56fe\u6807 (\u6216\u6309 Ctrl&#043;Shift&#043;X)\u3002<\/li>\n<li>\u641c\u7d22\u5e76\u5b89\u88c5\u4ee5\u4e0b\u6269\u5c55&#xff1a;\n<ul>\n<li>C\/C&#043;&#043;: \u7531 Microsoft \u63d0\u4f9b\u3002\u63d0\u4f9b\u8bed\u8a00\u652f\u6301 (IntelliSense, \u8c03\u8bd5\u7b49)\u3002<\/li>\n<li>(\u53ef\u9009) Code Runner: \u65b9\u4fbf\u5feb\u901f\u8fd0\u884c\u4ee3\u7801\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>&#x1f6e0; \u56db\u3001 \u914d\u7f6e VS Code \u7684 C\/C&#043;&#043; \u73af\u5883<\/h4>\n<p>\u8fd9\u662f\u6700\u5173\u952e\u7684\u4e00\u6b65&#xff0c;\u9700\u8981\u521b\u5efa\u914d\u7f6e\u6587\u4ef6\u3002<\/p>\n<li>\u521b\u5efa\u4e00\u4e2a\u9879\u76ee\u6587\u4ef6\u5939:\n<ul>\n<li>\u5728 VS Code \u4e2d&#xff0c;\u70b9\u51fb \u6587\u4ef6 -&gt; \u6253\u5f00\u6587\u4ef6\u5939&#xff0c;\u9009\u62e9\u4e00\u4e2a\u7a7a\u6587\u4ef6\u5939\u6216\u65b0\u5efa\u4e00\u4e2a\u3002<\/li>\n<li>\u4f8b\u5982 D:\\\\cpp_projects\\\\hello_world\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u521b\u5efa\u4f60\u7684\u7b2c\u4e00\u4e2a C\/C&#043;&#043; \u6587\u4ef6:\n<ul>\n<li>\u5728\u8d44\u6e90\u7ba1\u7406\u5668\u89c6\u56fe\u4e2d&#xff0c;\u53f3\u952e\u70b9\u51fb\u4f60\u7684\u9879\u76ee\u6587\u4ef6\u5939 -&gt; \u65b0\u5efa\u6587\u4ef6\u3002<\/li>\n<li>\u547d\u540d\u4e3a main.cpp (C&#043;&#043;) \u6216 main.c (C)\u3002<\/li>\n<li>\u8f93\u5165\u4e00\u4e2a\u7b80\u5355\u7684\u7a0b\u5e8f&#xff0c;\u4f8b\u5982&#xff1a; #include &lt;iostream&gt;<br \/>\nint main() {<br \/>\n    std::cout &lt;&lt; &#034;Hello, VS Code and C&#043;&#043;!&#034; &lt;&lt; std::endl;<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>https:\/\/www.zhihu.com\/zvideo\/2008731309795717775 https:\/\/www.zhihu.com\/zvideo\/2008731201670780077 https:\/\/www.zhihu.com\/zvideo\/2008730918874007188 https:\/\/www.zhihu.com\/zvideo\/2008730503633737216 https:\/\/www.zhihu.com\/zvideo\/2008730026888157105 https:\/\/www.zhihu.com\/zvideo\/2008730026888157105\/ https:\/\/www.zhihu.com\/zvideo\/2008730503633737216\/ https:\/\/www.zhihu.com\/zvideo\/2008731309795717775\/ https:\/\/www.zhihu.com\/zvideo\/2008730918874007188\/ https:\/\/www.zhihu.com\/zvideo\/2008731201670780077\/ \u00a0<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u751f\u6210\u7f16\u8bd1\u4efb\u52a1 (tasks.json):\n<ul>\n<li>\u6309 Ctrl&#043;Shift&#043;B \u6216\u70b9\u51fb \u7ec8\u7aef -&gt; \u8fd0\u884c\u751f\u6210\u4efb\u52a1&#8230;\u3002<\/li>\n<li>\u7531\u4e8e\u8fd9\u662f\u7b2c\u4e00\u6b21&#xff0c;VS Code \u4f1a\u63d0\u793a \u672a\u627e\u5230\u751f\u6210\u4efb\u52a1\u3002\u9009\u62e9 \u914d\u7f6e\u751f\u6210\u4efb\u52a1&#8230;\u3002<\/li>\n<li>\u9009\u62e9 \u4f7f\u7528\u6a21\u677f\u521b\u5efa tasks.json \u6587\u4ef6\u3002<\/li>\n<li>\u9009\u62e9 Others\u3002<\/li>\n<li>\u8fd9\u4f1a\u521b\u5efa\u4e00\u4e2a .vscode \u6587\u4ef6\u5939&#xff0c;\u5e76\u5728\u5176\u4e2d\u751f\u6210 tasks.json \u6587\u4ef6\u3002<\/li>\n<li>\u7528\u4ee5\u4e0b\u5185\u5bb9\u66ff\u6362 tasks.json \u7684\u5185\u5bb9&#xff1a; {<br \/>\n    &#034;version&#034;: &#034;2.0.0&#034;,<br \/>\n    &#034;tasks&#034;: [<br \/>\n        {<br \/>\n            &#034;label&#034;: &#034;Build with g&#043;&#043;&#034;, \/\/ \u7ed9\u4efb\u52a1\u8d77\u4e2a\u540d\u5b57<br \/>\n            &#034;type&#034;: &#034;shell&#034;,<br \/>\n            &#034;command&#034;: &#034;g&#043;&#043;&#034;,<br \/>\n            &#034;args&#034;: [<br \/>\n                &#034;-g&#034;, \/\/ \u751f\u6210\u8c03\u8bd5\u4fe1\u606f<br \/>\n                &#034;${file}&#034;, \/\/ \u7f16\u8bd1\u5f53\u524d\u6587\u4ef6<br \/>\n                &#034;-o&#034;, \/\/ \u6307\u5b9a\u8f93\u51fa\u6587\u4ef6<br \/>\n                &#034;${fileDirname}\\\\\\\\${fileBasenameNoExtension}.exe&#034; \/\/ \u8f93\u51fa\u6587\u4ef6\u8def\u5f84<br \/>\n            ],<br \/>\n            &#034;group&#034;: {<br \/>\n                &#034;kind&#034;: &#034;build&#034;,<br \/>\n                &#034;isDefault&#034;: true<br \/>\n            },<br \/>\n            &#034;problemMatcher&#034;: &#034;$gcc&#034;<br \/>\n        }<br \/>\n    ]<br \/>\n}<\/p>\n<\/li>\n<li>\u8bf4\u660e:\n<ul>\n<li>label: \u4efb\u52a1\u540d\u79f0&#xff0c;\u663e\u793a\u5728\u4efb\u52a1\u5217\u8868\u4e2d\u3002<\/li>\n<li>type: \u901a\u5e38\u662f shell \u6216 process\u3002<\/li>\n<li>command: \u7f16\u8bd1\u5668\u7684\u53ef\u6267\u884c\u6587\u4ef6 (g&#043;&#043; \u7528\u4e8e C&#043;&#043;, gcc \u7528\u4e8e C)\u3002<\/li>\n<li>args: \u4f20\u9012\u7ed9\u7f16\u8bd1\u5668\u7684\u53c2\u6570\u3002\n<ul>\n<li>-g: \u751f\u6210\u8c03\u8bd5\u4fe1\u606f (\u91cd\u8981&#xff01;\u7528\u4e8e\u8c03\u8bd5)\u3002<\/li>\n<li>${file}: \u5f53\u524d\u6d3b\u52a8\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84\u3002<\/li>\n<li>-o: \u544a\u8bc9\u7f16\u8bd1\u5668\u63a5\u4e0b\u6765\u662f\u8f93\u51fa\u6587\u4ef6\u540d\u3002<\/li>\n<li>${fileDirname}\\\\\\\\${fileBasenameNoExtension}.exe: \u8f93\u51fa\u7684\u53ef\u6267\u884c\u6587\u4ef6\u8def\u5f84\u548c\u540d\u79f0\u3002<\/li>\n<\/ul>\n<\/li>\n<li>group: \u5c06\u6b64\u4efb\u52a1\u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u7684\u751f\u6210\u4efb\u52a1 (Ctrl&#043;Shift&#043;B \u4f1a\u8fd0\u884c\u5b83)\u3002<\/li>\n<li>problemMatcher: \u5e2e\u52a9\u89e3\u6790\u7f16\u8bd1\u9519\u8bef\u8f93\u51fa\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\u914d\u7f6e\u8c03\u8bd5\u8bbe\u7f6e (launch.json):\n<ul>\n<li>\n<p>\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u7684 \u8fd0\u884c\u548c\u8c03\u8bd5 \u56fe\u6807 (\u6216\u6309 Ctrl&#043;Shift&#043;D)\u3002<\/p>\n<\/li>\n<li>\n<p>\u70b9\u51fb\u9876\u90e8 \u8fd0\u884c\u548c\u8c03\u8bd5 \u65c1\u8fb9\u7684\u4e0b\u62c9\u7bad\u5934 -&gt; \u6dfb\u52a0\u914d\u7f6e&#8230; -&gt; \u9009\u62e9 C&#043;&#043; (GDB\/LLDB)\u3002<\/p>\n<\/li>\n<li>\n<p>\u8fd9\u4f1a\u751f\u6210 launch.json \u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>\u7528\u4ee5\u4e0b\u5185\u5bb9\u66ff\u6362 launch.json \u7684\u5185\u5bb9 (\u9009\u62e9\u9002\u5408\u4f60\u60c5\u51b5\u7684\u914d\u7f6e)&#xff1a;<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u4e00&#xff1a;\u8c03\u8bd5\u5f53\u524d\u6587\u4ef6 (\u6700\u5e38\u7528)<\/p>\n<p> {<br \/>\n    &#034;version&#034;: &#034;0.2.0&#034;,<br \/>\n    &#034;configurations&#034;: [<br \/>\n        {<br \/>\n            &#034;name&#034;: &#034;Debug current file (g&#043;&#043;)&#034;,<br \/>\n            &#034;type&#034;: &#034;cppdbg&#034;,<br \/>\n            &#034;request&#034;: &#034;launch&#034;,<br \/>\n            &#034;program&#034;: &#034;${fileDirname}\\\\\\\\${fileBasenameNoExtension}.exe&#034;,<br \/>\n            &#034;args&#034;: [],<br \/>\n            &#034;stopAtEntry&#034;: false,<br \/>\n            &#034;cwd&#034;: &#034;${fileDirname}&#034;,<br \/>\n            &#034;environment&#034;: [],<br \/>\n            &#034;externalConsole&#034;: true, \/\/ \u4f7f\u7528\u5916\u90e8\u63a7\u5236\u53f0\u7a97\u53e3 (Windows)<br \/>\n            &#034;MIMode&#034;: &#034;gdb&#034;,<br \/>\n            &#034;miDebuggerPath&#034;: &#034;gdb&#034;, \/\/ MinGW \u8c03\u8bd5\u5668<br \/>\n            &#034;setupCommands&#034;: [<br \/>\n                {<br \/>\n                    &#034;description&#034;: &#034;Enable pretty-printing for gdb&#034;,<br \/>\n                    &#034;text&#034;: &#034;-enable-pretty-printing&#034;,<br \/>\n                    &#034;ignoreFailures&#034;: true<br \/>\n                }<br \/>\n            ],<br \/>\n            &#034;preLaunchTask&#034;: &#034;Build with g&#043;&#043;&#034; \/\/ \u786e\u4fdd\u4e0e tasks.json \u4e2d\u7684 label \u4e00\u81f4<br \/>\n        }<br \/>\n    ]<br \/>\n}<\/p>\n<p>https:\/\/www.zhihu.com\/zvideo\/2008731309795717775 https:\/\/www.zhihu.com\/zvideo\/2008731201670780077 https:\/\/www.zhihu.com\/zvideo\/2008730918874007188 https:\/\/www.zhihu.com\/zvideo\/2008730503633737216 https:\/\/www.zhihu.com\/zvideo\/2008730026888157105 https:\/\/www.zhihu.com\/zvideo\/2008730026888157105\/ https:\/\/www.zhihu.com\/zvideo\/2008730503633737216\/ https:\/\/www.zhihu.com\/zvideo\/2008731309795717775\/ https:\/\/www.zhihu.com\/zvideo\/2008730918874007188\/ https:\/\/www.zhihu.com\/zvideo\/2008731201670780077\/ \u00a0<\/p>\n<\/li>\n<li>\n<p>\u914d\u7f6e\u4e8c&#xff1a;\u8c03\u8bd5\u591a\u4e2a\u6587\u4ef6 (\u9879\u76ee)<\/p>\n<p> {<br \/>\n    &#034;version&#034;: &#034;0.2.0&#034;,<br \/>\n    &#034;configurations&#034;: [<br \/>\n        {<br \/>\n            &#034;name&#034;: &#034;Debug project (g&#043;&#043;)&#034;,<br \/>\n            &#034;type&#034;: &#034;cppdbg&#034;,<br \/>\n            &#034;request&#034;: &#034;launch&#034;,<br \/>\n            &#034;program&#034;: &#034;${workspaceFolder}\\\\\\\\build\\\\\\\\${workspaceFolderBasename}.exe&#034;, \/\/ \u5047\u8bbe\u8f93\u51fa\u5728 build \u6587\u4ef6\u5939<br \/>\n            &#034;args&#034;: [],<br \/>\n            &#034;stopAtEntry&#034;: false,<br \/>\n            &#034;cwd&#034;: &#034;${workspaceFolder}&#034;,<br \/>\n            &#034;environment&#034;: [],<br \/>\n            &#034;externalConsole&#034;: true,<br \/>\n            &#034;MIMode&#034;: &#034;gdb&#034;,<br \/>\n            &#034;miDebuggerPath&#034;: &#034;gdb&#034;,<br \/>\n            &#034;setupCommands&#034;: [<br \/>\n                {<br \/>\n                    &#034;description&#034;: &#034;Enable pretty-printing for gdb&#034;,<br \/>\n                    &#034;text&#034;: &#034;-enable-pretty-printing&#034;,<br \/>\n                    &#034;ignoreFailures&#034;: true<br \/>\n                }<br \/>\n            ],<br \/>\n            &#034;preLaunchTask&#034;: &#034;Build project&#034; \/\/ \u9700\u8981\u4fee\u6539 tasks.json \u5b9a\u4e49\u6b64\u4efb\u52a1<br \/>\n        }<br \/>\n    ]<br \/>\n}<\/p>\n<\/li>\n<li>\n<p>\u8bf4\u660e:<\/p>\n<ul>\n<li>name: \u8c03\u8bd5\u914d\u7f6e\u7684\u540d\u79f0\u3002<\/li>\n<li>type: cppdbg \u8868\u793a C&#043;&#043; \u8c03\u8bd5\u3002<\/li>\n<li>request: launch \u8868\u793a\u542f\u52a8\u7a0b\u5e8f\u8fdb\u884c\u8c03\u8bd5\u3002<\/li>\n<li>program: \u8981\u8c03\u8bd5\u7684\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\u3002${fileDirname}\\\\\\\\${fileBasenameNoExtension}.exe \u5bf9\u5e94 tasks.json \u7684\u8f93\u51fa\u8def\u5f84\u3002<\/li>\n<li>preLaunchTask: \u975e\u5e38\u91cd\u8981&#xff01; \u6307\u5b9a\u5728\u8c03\u8bd5\u524d\u81ea\u52a8\u8fd0\u884c\u54ea\u4e2a\u751f\u6210\u4efb\u52a1 (\u5bf9\u5e94 tasks.json \u4e2d\u7684 label)\u3002\u8fd9\u786e\u4fdd\u4e86\u8c03\u8bd5\u7684\u662f\u6700\u65b0\u7f16\u8bd1\u7684\u7a0b\u5e8f\u3002<\/li>\n<li>externalConsole: \u8bbe\u7f6e\u4e3a true \u4f1a\u5728\u5916\u90e8\u7ec8\u7aef\u7a97\u53e3\u8fd0\u884c\u7a0b\u5e8f (Windows \u4e0b\u663e\u793a\u66f4\u597d)\u3002\u8bbe\u7f6e\u4e3a false \u5219\u4f7f\u7528 VS Code \u7684\u5185\u7f6e\u7ec8\u7aef\u3002<\/li>\n<li>MIMode: \u8c03\u8bd5\u5668\u6a21\u5f0f (gdb \u7528\u4e8e MinGW)\u3002<\/li>\n<li>miDebuggerPath: GDB \u8c03\u8bd5\u5668\u7684\u8def\u5f84 (\u901a\u5e38\u662f gdb)\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>(\u53ef\u9009) \u4fee\u6539 tasks.json \u4ee5\u7f16\u8bd1\u591a\u4e2a\u6587\u4ef6:\n<ul>\n<li>\u5982\u679c\u4f60\u7684\u9879\u76ee\u6709\u591a\u4e2a\u6e90\u6587\u4ef6&#xff0c;\u4fee\u6539 tasks.json \u4e2d\u7684 args&#xff1a; &#034;args&#034;: [<br \/>\n    &#034;-g&#034;,<br \/>\n    &#034;${fileDirname}\\\\\\\\*.cpp&#034;, \/\/ \u7f16\u8bd1\u6587\u4ef6\u5939\u4e0b\u6240\u6709 .cpp \u6587\u4ef6<br \/>\n    &#034;-o&#034;,<br \/>\n    &#034;${fileDirname}\\\\\\\\myprogram.exe&#034; \/\/ \u6307\u5b9a\u8f93\u51fa\u6587\u4ef6\u540d<br \/>\n],<\/p>\n<\/li>\n<li>\u6216\u8005\u66f4\u7cbe\u786e\u5730\u5217\u51fa\u6587\u4ef6 (\u63a8\u8350)&#xff1a; &#034;args&#034;: [<br \/>\n    &#034;-g&#034;,<br \/>\n    &#034;${fileDirname}\\\\\\\\main.cpp&#034;,<br \/>\n    &#034;${fileDirname}\\\\\\\\helper.cpp&#034;,<br \/>\n    &#034;-o&#034;,<br \/>\n    &#034;${fileDirname}\\\\\\\\myprogram.exe&#034;<br \/>\n],<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<h4>&#x1f680; \u4e94\u3001 \u7f16\u8bd1\u548c\u8fd0\u884c\/\u8c03\u8bd5<\/h4>\n<li>\u7f16\u8bd1:\n<ul>\n<li>\u6253\u5f00\u4f60\u7684\u6e90\u6587\u4ef6 (\u5982 main.cpp)\u3002<\/li>\n<li>\u6309 Ctrl&#043;Shift&#043;B \u6216\u70b9\u51fb \u7ec8\u7aef -&gt; \u8fd0\u884c\u751f\u6210\u4efb\u52a1\u3002<\/li>\n<li>VS Code \u4f1a\u8c03\u7528 tasks.json \u4e2d\u5b9a\u4e49\u7684\u547d\u4ee4\u8fdb\u884c\u7f16\u8bd1\u3002<\/li>\n<li>\u67e5\u770b \u7ec8\u7aef \u8f93\u51fa\u9762\u677f\u662f\u5426\u6709\u9519\u8bef\u3002\u6210\u529f\u7f16\u8bd1\u540e\u4f1a\u5728\u6e90\u6587\u4ef6\u540c\u76ee\u5f55\u751f\u6210 .exe \u6587\u4ef6\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u8fd0\u884c (\u4f7f\u7528 Code Runner):\n<ul>\n<li>\u5982\u679c\u5b89\u88c5\u4e86 Code Runner \u6269\u5c55\u3002<\/li>\n<li>\u53f3\u952e\u70b9\u51fb\u7f16\u8f91\u5668 -&gt; Run Code&#xff0c;\u6216\u6309 Ctrl&#043;Alt&#043;N\u3002<\/li>\n<li>\u8f93\u51fa\u4f1a\u663e\u793a\u5728 \u8f93\u51fa \u9762\u677f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u8c03\u8bd5:\n<ul>\n<li>\u5728\u6e90\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9 (\u70b9\u51fb\u884c\u53f7\u5de6\u4fa7\u7684\u7a7a\u767d\u5904)\u3002<\/li>\n<li>\u6309 F5 \u6216\u70b9\u51fb \u8fd0\u884c -&gt; \u542f\u52a8\u8c03\u8bd5\u3002<\/li>\n<li>VS Code \u4f1a\u5148\u6267\u884c preLaunchTask (\u7f16\u8bd1)&#xff0c;\u7136\u540e\u542f\u52a8\u8c03\u8bd5\u5668\u3002<\/li>\n<li>\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u680f (\u9876\u90e8\u51fa\u73b0\u7684\u5de5\u5177\u680f) \u8fdb\u884c \u7ee7\u7eed\u3001\u5355\u6b65\u8df3\u8fc7\u3001\u5355\u6b65\u8fdb\u5165\u3001\u91cd\u542f\u3001\u505c\u6b62 \u64cd\u4f5c\u3002<\/li>\n<li>\u67e5\u770b \u53d8\u91cf\u3001\u76d1\u89c6\u3001\u8c03\u7528\u5806\u6808 \u7b49\u8c03\u8bd5\u4fe1\u606f\u9762\u677f\u3002<\/li>\n<\/ul>\n<\/li>\n<h4>&#x1f9ea; \u516d\u3001 \u6d4b\u8bd5<\/h4>\n<li>\u786e\u4fdd\u4f60\u7684 main.cpp \u5305\u542b\u7b80\u5355\u7684\u8f93\u51fa\u4ee3\u7801\u3002<\/li>\n<li>\u5c1d\u8bd5\u7f16\u8bd1 (Ctrl&#043;Shift&#043;B) \u5e76\u67e5\u770b\u7ec8\u7aef\u8f93\u51fa\u3002<\/li>\n<li>\u5c1d\u8bd5\u8c03\u8bd5 (F5)&#xff0c;\u7a0b\u5e8f\u5e94\u8be5\u542f\u52a8\u5e76\u5728\u65ad\u70b9\u5904\u505c\u6b62 (\u5982\u679c\u8bbe\u7f6e\u4e86\u65ad\u70b9)&#xff0c;\u6216\u8005\u5728\u5916\u90e8\u63a7\u5236\u53f0\u8f93\u51fa &#034;Hello, VS Code and C&#043;&#043;!&#034;\u3002<\/li>\n<h4>&#x1f4cc; \u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul>\n<li>\u8def\u5f84\u5206\u9694\u7b26: Windows \u4f7f\u7528\u53cd\u659c\u6760 \\\\&#xff0c;Linux\/macOS \u4f7f\u7528\u6b63\u659c\u6760 \/\u3002${fileDirname} \u7b49\u53d8\u91cf\u4f1a\u81ea\u52a8\u5904\u7406\u3002<\/li>\n<li>\u73af\u5883\u53d8\u91cf: \u786e\u4fdd Path \u4e2d\u914d\u7f6e\u7684 MinGW bin \u8def\u5f84\u6b63\u786e\u4e14\u751f\u6548 (\u53ef\u80fd\u9700\u8981\u91cd\u542f VS Code \u6216\u7535\u8111)\u3002<\/li>\n<li>\u6587\u4ef6\u7f16\u7801: \u5efa\u8bae\u6e90\u6587\u4ef6\u4f7f\u7528 UTF-8 \u7f16\u7801\u3002<\/li>\n<li>\u8c03\u8bd5\u95ee\u9898: \u5982\u679c\u8c03\u8bd5\u5931\u8d25&#xff0c;\u68c0\u67e5 tasks.json \u7684\u8f93\u51fa\u8def\u5f84 (program) \u662f\u5426\u4e0e launch.json \u4e2d\u7684 program \u8def\u5f84\u4e00\u81f4&#xff0c;\u4ee5\u53ca preLaunchTask \u540d\u79f0\u662f\u5426\u5339\u914d\u3002\u786e\u4fdd\u7f16\u8bd1\u65f6\u4f7f\u7528\u4e86 -g \u9009\u9879\u751f\u6210\u8c03\u8bd5\u4fe1\u606f\u3002<\/li>\n<li>\u5916\u90e8\u63a7\u5236\u53f0: \u5982\u679c externalConsole \u8bbe\u4e3a true&#xff0c;\u7a0b\u5e8f\u4f1a\u5728\u4e00\u4e2a\u5355\u72ec\u7684\u9ed1\u8272\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u8fd0\u884c\u3002\u8c03\u8bd5\u7ed3\u675f\u540e&#xff0c;\u8fd9\u4e2a\u7a97\u53e3\u53ef\u80fd\u4f1a\u81ea\u52a8\u5173\u95ed\u3002\u5982\u679c\u770b\u4e0d\u5230\u8f93\u51fa&#xff0c;\u5c1d\u8bd5\u5c06\u5176\u8bbe\u4e3a false \u4f7f\u7528\u5185\u7f6e\u7ec8\u7aef\u3002<\/li>\n<li>\u66f4\u65b0: \u7f16\u8bd1\u5668\u3001VS Code \u548c C\/C&#043;&#043; \u6269\u5c55\u90fd\u53ef\u80fd\u66f4\u65b0&#xff0c;\u5173\u6ce8\u66f4\u65b0\u65e5\u5fd7\u3002<\/li>\n<\/ul>\n<p>\u6309\u7167\u8fd9\u4e9b\u6b65\u9aa4\u64cd\u4f5c&#xff0c;\u4f60\u5e94\u8be5\u80fd\u591f\u5728 VS Code \u4e2d\u987a\u5229\u7f16\u5199\u3001\u7f16\u8bd1\u548c\u8c03\u8bd5 C\/C&#043;&#043; \u7a0b\u5e8f\u4e86\u3002\u795d\u4f60\u7f16\u7a0b\u6109\u5feb&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684 VS Code \u914d\u7f6e C\/C \u5f00\u53d1\u73af\u5883\u7684\u6b65\u9aa4\u6307\u5357&#xff1a;<br \/>\n&#x1f4dd; \u4e00\u3001 \u5b89\u88c5\u5fc5\u8981\u7684\u7f16\u8bd1\u5de5\u5177\u94fe (\u4ee5 Windows \u4e3a\u4f8b&#xff0c;\u4f7f\u7528 MinGW)<br \/>\n\u4e0b\u8f7d MinGW-w64: \u8bbf\u95ee MinGW-w64 \u5b98\u7f51 \u6216 SourceForge \u4e0b\u8f7d\u9875\u9762\u3002\u9009\u62e9\u6700\u65b0\u7248\u672c&#xff08;\u5982 x86_64-posix-seh&#xff09;\u7684\u5b89\u88c5\u7a0b\u5e8f\u4e0b\u8f7d\u3002 \u5b89\u88c5 MinGW-w64: \u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u9009\u9879\u4e2d\u9009\u62e9&amp;#xff<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,174,76],"topic":[],"class_list":{"0":"post-76268","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-server","7":"tag-c","9":"tag-vscode"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/76268.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684 VS Code \u914d\u7f6e C\/C \u5f00\u53d1\u73af\u5883\u7684\u6b65\u9aa4\u6307\u5357&#xff1a; &#x1f4dd; \u4e00\u3001 \u5b89\u88c5\u5fc5\u8981\u7684\u7f16\u8bd1\u5de5\u5177\u94fe (\u4ee5 Windows \u4e3a\u4f8b&#xff0c;\u4f7f\u7528 MinGW) \u4e0b\u8f7d MinGW-w64: \u8bbf\u95ee MinGW-w64 \u5b98\u7f51 \u6216 SourceForge \u4e0b\u8f7d\u9875\u9762\u3002\u9009\u62e9\u6700\u65b0\u7248\u672c&#xff08;\u5982 x86_64-posix-seh&#xff09;\u7684\u5b89\u88c5\u7a0b\u5e8f\u4e0b\u8f7d\u3002 \u5b89\u88c5 MinGW-w64: \u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u9009\u9879\u4e2d\u9009\u62e9&amp;#xff\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/76268.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-21T18:41:18+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76268.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/76268.html\",\"name\":\"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-21T18:41:18+00:00\",\"dateModified\":\"2026-02-21T18:41:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/76268.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/76268.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/76268.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/76268.html","og_locale":"zh_CN","og_type":"article","og_title":"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u597d\u7684&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684 VS Code \u914d\u7f6e C\/C \u5f00\u53d1\u73af\u5883\u7684\u6b65\u9aa4\u6307\u5357&#xff1a; &#x1f4dd; \u4e00\u3001 \u5b89\u88c5\u5fc5\u8981\u7684\u7f16\u8bd1\u5de5\u5177\u94fe (\u4ee5 Windows \u4e3a\u4f8b&#xff0c;\u4f7f\u7528 MinGW) \u4e0b\u8f7d MinGW-w64: \u8bbf\u95ee MinGW-w64 \u5b98\u7f51 \u6216 SourceForge \u4e0b\u8f7d\u9875\u9762\u3002\u9009\u62e9\u6700\u65b0\u7248\u672c&#xff08;\u5982 x86_64-posix-seh&#xff09;\u7684\u5b89\u88c5\u7a0b\u5e8f\u4e0b\u8f7d\u3002 \u5b89\u88c5 MinGW-w64: \u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u9009\u9879\u4e2d\u9009\u62e9&amp;#xff","og_url":"https:\/\/www.wsisp.com\/helps\/76268.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-21T18:41:18+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/76268.html","url":"https:\/\/www.wsisp.com\/helps\/76268.html","name":"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-21T18:41:18+00:00","dateModified":"2026-02-21T18:41:18+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/76268.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/76268.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/76268.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"VSCode\u914d\u7f6eC\/C++\u73af\u5883\u5168\u653b\u7565"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=76268"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/76268\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=76268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=76268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=76268"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=76268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}