In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the method of writing c language in vscode. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
1. Install vscode (version 1.27)
Https://code.visualstudio.com/ download and install vscode.
2. Install the cripple censor + extension.
3. Install the compilation tool mingw-w64, http://www.mingw-w64.org/doku.php/download
Configure environment variables. Take WIN10 as an example, this computer-Properties-Advanced system Settings-Environment variables-system variables-path- add a D:\ Program Files\ mingw-w64\ i686-8.1.0-posix-dwarf-rt_v6-rev0\ mingw32\ bin (you install the compiler tool path)
Before configuration
After configuration
-ps: if the environment variable is configured with vscode on, disable vscode and turn it on again after configuration.
4. Configuration file launch.json,task.json.
Create a new file hello.cpp
Press F5 to pop up to select the environment and configure launch.json
Click in, and the content in configurations: is as follows:
{"name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "enter program name, for example ${workspaceFolder} / a.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerPath": "/ path/to/gdb" "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}]}
Modify it as follows:
{"name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder} / a.exe", / / delete here and there enter program name, for example "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": true, "MIMode": "gdb" "miDebuggerPath": "D:\\ Program Files\\ mingw-w64\\ i686-8.1.0-posix-dwarf-rt_v6-rev0\\ mingw32\\ bin\\ gdb.exe", / / modify the path where you installed mingw32 "setupCommands": [{"description": "Enable pretty-printing for gdb", "text": "- enable-pretty-printing", "ignoreFailures": true}], "preLaunchTask": "build hello" / / name in task.json}
When you go back to hello.cpp, press F5 to pop up the error box and select the configuration task.
Click, then select Others, and task.json appears as follows:
"version": "2.0.0", "tasks": [{"label": "echo", "type": "shell", "command": "echo Hello"}]
The modifications are as follows:
"version": "2.0.0", "tasks": [{"label": "build hello", "type": "shell", "command": "command +", "args": ["- g", "hello.cpp",] "group": {"kind": "build", "isDefault": true}}]
Note: if it is a win32 program (window interface), add "- mwindows" to the args.
Go back to the hello.cpp file and press F5. The compilation ran successfully.
5. It is also found that the Chinese console shows garbled codes.
Just click utf-8 in the lower right corner.
Click Save with Code, select GBK, and then press F5 to run.
This is the end of the method of writing c language in vscode. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.