VisualStudioCode配置c/c++环境(插件C/C++ Compile Run使用)

     目前VisualStudioCode编译器配置c/c++编译环境的的教程,都是基于C/C++ for Visual Studio Code插件的。使用的时候需要配置tasks.json、   launch.json、 c_cpp_properties.json文件。
  其实可以直接安装对应的插件,使用系统环境中配置好的c/c++编译环境。

配置步骤:

  1. 系统环境变量中添加c编译环境路径:(这里使用的是codeblock的mingw路径)在这里插入图片描述
  2. 安装Visual Studio Code第三方插件“C/C++ Compile Run
    在这里插入图片描述
    3.使用 .c 文件验证一下
    (文件保存后,按 F6 完成文件的编译运行 ,或按F7,这将使用您为程序指定的参数)
    在这里插入图片描述

完美!!!

Sure! Here is a detailed guide on how to configure the C/C++ environment in Visual Studio Code (VSCode): 1. Install Visual Studio Code: Download and install VSCode from the official website (https://code.visualstudio.com/). 2. Install the C/C++ extension: Open VSCode and go to the Extensions view by clicking on the square icon on the left sidebar or by pressing `Ctrl+Shift+X`. Search for "C/C++" in the search bar, and click on the extension provided by Microsoft. Click on the "Install" button to install the extension. 3. Install a C/C++ compiler: To compile and run C/C++ code, you need a compiler. The most popular choice is GCC (GNU Compiler Collection). Install GCC based on your operating system: - Windows: Install MinGW-w64 (https://mingw-w64.org/doku.php). - macOS: Install Xcode Command Line Tools by running `xcode-select --install` in the terminal. - Linux: Install GCC using your package manager. For example, on Ubuntu, run `sudo apt-get install build-essential`. 4. Configure the compiler path: Open VSCode and go to the Settings view by clicking on the gear icon on the left sidebar or by pressing `Ctrl+,`. Search for "C_Cpp: Default Compiler Path" and click on "Edit in settings.json". Set the path to your C/C++ compiler executable. For example, if you installed MinGW-w64 on Windows, the path might be something like `"C:\\mingw-w64\\mingw64\\bin\\gcc.exe"`. 5. Create a new C/C++ project: Open a new folder in VSCode by going to File -> Open Folder. Create a new file with a `.c` or `.cpp` extension and start writing your C/C++ code. 6. Build and run your code: To build and run your code, you can use the integrated terminal in VSCode. Press `Ctrl+` backtick (`) to open the terminal. Use the following commands: - For C code: `gcc filename.c -o outputname && ./outputname` - For C++ code: `g++ filename.cpp -o outputname && ./outputname` That's it! You have successfully configured the C/C++ environment in VSCode. You can now write, build, and run C/C++ code directly from the editor.
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值