Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Can ​ vscode write c programs?

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the vscode can write c program, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Can vscode write c programs?

Writing C language by VSCode

Get the CAccord Category + extension

Open vscode

Ctrl+shift+x, open the store.

Search for CAccord Category +

Install and restart vscode

Install GCC

Download MinGW

Open the installer, install to disk D (need to create a MinGW folder), and generate the MinGW installation manager after the installation is complete.

Manager automatically opens (if not manually), click All Packages, select gcc.bin,g++.bin,gdb.bin, click Installation, select Apply Changes, click Apply submit to install

Win+R, enter control to enter the control panel, click system and install-> system-> Advanced system Settings-> Environment variables, find Path- > Edit-> New, and paste the bin folder path of the installed MinGW.

Configure Smart Tip

Write a test file demo.c, click the "prompt light" under the introduced standard library, and generate the c_cpp_properties.json file.

Edit c_cpp_properties.json

The modification of c_cpp_properties.json is as follows:

{"configurations": [{"name": "Win32", "includePath": ["${workspaceFolder} / * *"], "defines": ["_ DEBUG", "UNICODE", "_ UNICODE"] "windowsSdkVersion": "8.1", "compilerPath": "D:\\ MinGW\\ bin\\ gcc.exe", / / the gcc path on your computer "cStandard": "c11", "cppStandard": "clockwise 17", "intelliSenseMode": "msvc-x64"}], "version": 4}

Turn on debugging function

F5 or Ctrl+F5 enable debugging, select C++ (GDB/LLDB) to generate launch.json file, and modify as follows:

{/ / use IntelliSense to learn about the relevant properties. / / hover to see a description of an existing property. / / for more information Please visit https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [{"name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder} / ${fileBasenameNoExtension} .exe" / / debugged program "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "D:\\ MinGW\\ bin\\ gdb.exe" / / gdb "preLaunchTask" of your computer: "echo", / / the name of the task to be executed before debugging: "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing" "ignoreFailures": true}]}]}

Ctrl+Shift+P, enter the Tasks:Configure Task configuration task, select the module to create the task.json file, select the Others template, and generate the task.json file. Modify as follows:

{/ / See https://go.microsoft.com/fwlink/?LinkId=733558 / / for the documentation about the tasks.json format "version": "2.0.0", "tasks": [{"label": "echo", / / Task name "type": "shell", "command": "gcc" "args": ["- g", "${file}", "- o", "${fileBasenameNoExtension} .exe" / / generate a debuggable execution file]}]}

If there is an error: process termination, exit code: 1, it may be that gcc has not been loaded by the editor (test method: open the console, enter gcc, see the prompt), restart the editor.

Thank you for reading this article carefully. I hope the article "can vscode write c program" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report