VSCode configuration to run C language project

To configure and run a C language project in Visual Studio Code (VS Code), follow these steps:

  1. Install Visual Studio Code :

    • Download and install Visual Studio Code from the official website . The installation process is fairly simple, just accept the agreement, keep the default settings, and complete the installation.
  2. Install the C/C++ compiler :

    • VS Code itself does not include a C/C++ compiler. For Windows users, you can download and install MinGW64. For Mac users, use Xcode, for Linux users, use GCC. After installation, make sure to add the compiler path to your system's environment variables.
  3. Install the extension in VS Code :

    • Open VS Code and go to the Extensions tab.
    • Search and install C/C++ extensions officially verified by Microsoft.
    • Also install the C/C++ extension package.
    • You also need to search for and install the Code Runner extension.
  4. Change settings :

    • In VS Code, click the gear icon in the lower right corner (Admin section), then click Settings. Alternatively, you can use the shortcut key Ctrl+ ,.
    • Type "Run code in terminal" in the search bar and press Enter.
    • Scroll down until you find it Code-runner: Run In Terminal. Make sure this checkbox is checked.
  5. Test your code :

    • Open VS Code, open any folder and create a .cC file with extension or .cppC++ file with extension.
    • After writing the code, you can run it directly using the play button in the upper right corner.
  6. Run and debug C/C++ code :

    • launch.jsonVS Code can create and automatically configure the and files when you first try to debug tasks.json.
    • Select C++ (GDB/LLDB), then select g++.exe build and debug active file.

Make sure you download the correct files for your operating system and set the environment variables correctly. If you encounter any problems during installation or configuration, you can refer to relevant tutorials or seek professional help.

References:

Guess you like

Origin blog.csdn.net/r081r096/article/details/135439888