To run a C program in Visual Studio Code, follow these steps:

  1. Install the C/C++ Extension: Ensure you have the C/C++ extension installed in Visual Studio Code. You mentioned you have this set up, which is great.
  2. Set Up a Workspace: Create a new folder for your C projects. Open Visual Studio Code and select File > Open Folder... to open your newly created folder.
  3. Create a C File: Inside your workspace folder, create a new file with a .c extension (e.g., hello.c). You can do this by right-clicking in the Explorer pane and selecting New File.
  4. Write Your Code: Write your C code in the newly created file. For example:
       #include 
       
       int main() {
           printf("Hello, World!\n");
           return 0;
       }
    
  5. Configure Build Tasks: You need to set up a build task to compile your C code. Press Ctrl + Shift + B to open the build tasks menu. If prompted, select Create tasks.json file from template and choose Others. Modify the generated tasks.json file to include the following:
       {
           "version": "2.0.0",
           "tasks": [
               {
                   "label": "build",
                   "type": "shell",
                   "command": "gcc",
                   "args": [
                       "-g",
                       "${file}",
                       "-o",
                       "${fileDirname}/${fileBasenameNoExtension}"
                   ],
                   "group": {
                       "kind": "build",
                       "isDefault": true
                   },
                   "problemMatcher": [
                       "$gcc"
                   ],
                   "detail": "Generated task by gcc"
               }
           ]
       }
    
  6. Build Your Program: Press Ctrl + Shift + B again to build your program. This will compile your C code and create an executable in the same directory.
  7. Run Your Program: Open the terminal in Visual Studio Code (View > Terminal or `Ctrl + ``) and run your program by typing:
       ./hello
    
    (Replace hello with the name of your executable if different.)
  8. Debugging: To debug your program, you will need to set up a launch configuration. Go to the Run view (left sidebar) and click on create a launch.json file. Choose C/C++: g++ build and debug active file. This will create a launch.json file where you can configure debugging settings.
  9. Start Debugging: Set breakpoints in your code by clicking in the gutter next to the line numbers. Then, press F5 to start debugging your program.

By following these steps, you should be able to set up Visual Studio Code for C programming and run your code successfully.


References:

  • Walkthrough: Compile a C program on the command line
Answer from AI answer on learn.microsoft.com
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ languages โ€บ cpp
C/C++ for Visual Studio Code
November 3, 2021 - To make sure the compiler is installed and configured correctly, lets create a Hello World C++ program. On Windows, launch a Windows command prompt (Enter Windows command prompt in the Windows search bar). On macOS and Linux, you can enter these commands in the terminal. Run the following commands.
๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ how-to-write-and-run-c-cpp-code-on-visual-studio-code
How to Write And Run C and C++ Code in Visual Studio Code
January 20, 2023 - Scroll down a little bit until you find Code-runner: Run In Terminal. Make sure that the box is checked (โœ”). ... Now you need to restart your VS Code/VS Code Insiders. Simply close and reopen the program.
Discussions

How to run a C program in Visual Studio Code? - Stack Overflow
I used to use Replit for my IDE, but I want to try Visual Studio Code (VSC) because my teacher said VSC was a great IDE to use. So I took a program I wrote a while back and put it in, but when I tr... More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to execute a C program in VS Code - Stack Overflow
Okay, I am an idiot and I cannot figure out how to compile and run C program in VS Code. How should I do it? I typed in the code itself, so what is next in order for me to see the output in terminal? More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to compile C program in Visual Studio Code? - Stack Overflow
Communities for your favorite technologies. Explore all Collectives ยท Turn scattered docs and code into trusted AI context. Explore the new Stack Internal platform More on stackoverflow.com
๐ŸŒ stackoverflow.com
How do I compile and run?
Like the other comment states, I also use the terminal. For C, I used 'make filename.c' to compile. Then 'run filename' to run the executable file. For Python, i use 'python filename.py' since you don't need to complie More on reddit.com
๐ŸŒ r/vscode
11
6
September 4, 2024
Top answer
1 of 1
4

To run a C program in Visual Studio Code, follow these steps:

  1. Install the C/C++ Extension: Ensure you have the C/C++ extension installed in Visual Studio Code. You mentioned you have this set up, which is great.
  2. Set Up a Workspace: Create a new folder for your C projects. Open Visual Studio Code and select File > Open Folder... to open your newly created folder.
  3. Create a C File: Inside your workspace folder, create a new file with a .c extension (e.g., hello.c). You can do this by right-clicking in the Explorer pane and selecting New File.
  4. Write Your Code: Write your C code in the newly created file. For example:
       #include 
       
       int main() {
           printf("Hello, World!\n");
           return 0;
       }
    
  5. Configure Build Tasks: You need to set up a build task to compile your C code. Press Ctrl + Shift + B to open the build tasks menu. If prompted, select Create tasks.json file from template and choose Others. Modify the generated tasks.json file to include the following:
       {
           "version": "2.0.0",
           "tasks": [
               {
                   "label": "build",
                   "type": "shell",
                   "command": "gcc",
                   "args": [
                       "-g",
                       "${file}",
                       "-o",
                       "${fileDirname}/${fileBasenameNoExtension}"
                   ],
                   "group": {
                       "kind": "build",
                       "isDefault": true
                   },
                   "problemMatcher": [
                       "$gcc"
                   ],
                   "detail": "Generated task by gcc"
               }
           ]
       }
    
  6. Build Your Program: Press Ctrl + Shift + B again to build your program. This will compile your C code and create an executable in the same directory.
  7. Run Your Program: Open the terminal in Visual Studio Code (View > Terminal or `Ctrl + ``) and run your program by typing:
       ./hello
    
    (Replace hello with the name of your executable if different.)
  8. Debugging: To debug your program, you will need to set up a launch configuration. Go to the Run view (left sidebar) and click on create a launch.json file. Choose C/C++: g++ build and debug active file. This will create a launch.json file where you can configure debugging settings.
  9. Start Debugging: Set breakpoints in your code by clicking in the gutter next to the line numbers. Then, press F5 to start debugging your program.

By following these steps, you should be able to set up Visual Studio Code for C programming and run your code successfully.


References:

  • Walkthrough: Compile a C program on the command line
๐ŸŒ
PW Skills
pwskills.com โ€บ blog โ€บ cpp โ€บ c-programming-in-vs-code
Can I Use C Programming in VS Code? Explained in Detail!
October 30, 2025 - Build and Run: Use the integrated terminal to navigate to the directory containing your C file and use a command like gcc filename.c -o output && ./output to build and run the program.
๐ŸŒ
3.0 University
3university.io โ€บ home โ€บ learn articles โ€บ how to compile and run a c program in vs code, terminal and turbo c++
How to Compile and Run a C Program in VS Code, Terminal and Turbo C++ - 3.0 University
August 31, 2026 - Install VS Code, then install the Microsoft C/C++ extension and the Code Runner extension. Make sure GCC or MinGW is installed on your system. Open your .c file, press Ctrl+Shift+B to build, then run the output in VS Codeโ€™s integrated terminal.
๐ŸŒ
Quora
quora.com โ€บ How-can-I-run-a-C-program-in-a-Visual-Studio-Code
How to run a C program in a Visual Studio Code - Quora
Answer (1 of 8): * You should first go to option create a new project in file menu. * Then enter the name of project press OK and accept the defaults and press finish. * Then a new terminal is opened for you on the screen . * Then you should type a syntactically correct program. [code]For exa...
Find elsewhere
๐ŸŒ
Medium
medium.com โ€บ @yutung3397 โ€บ getting-started-how-do-i-run-a-program-in-visual-studio-code-15c6193c34b5
Getting Started โ€” How do I run a program in Visual Studio Code? | by Michelle Cu | Medium
July 8, 2025 - { "version": "2.0.0", "tasks": ... } ] } For the output to appear in the terminal, first press shift+command+p to open the configuration palette, then click on Run Task ....
Top answer
1 of 2
3

The guide for using C++ with Visual Studio Code is located here:

  • C/C++ for Visual Studio Code

If you are using the windows operating system, you can install the Microsoft Visual C++ (MSVC) compiler toolset as described here:

  • Configure VS Code for Microsoft C++

Otherwise you should read the tutorials for the compiler you want to use:

  • Tutorials for other compilers

The reason I refer to links, instead of explaining the details here, is because the answer might become outdated/obsolete. Sometimes links are better than explanations.

2 of 2
2

Step 1. Download the MinGW - Minimalist GNU for Windows at SourceForge, link here.

When you download Minimalist GNU for Windows (MinGW), you can choose which packages to install. You should select the following packages:

  • mingw-developer-toolkit
  • mingw32-base
  • mingw32-gcc-g++
  • msys-base

Then click on the Installation tab on the top left and click on Apply Changes.

After installation, go to your C Drive where the MinGW is installed, and enter the folders MinGW > bin. Copy the path C:\MinGW\bin

Now search for environment, and enter edit environment variables for your account. screenshot

Next, double-click on Path, click on New, paste the path C:\MinGW\bin, press enter, and click OK.

Verify that it has been installed correctly by opening up Command Prompt and typing in gcc --version. It should give you the current version number.

Step 2. In Visual Studio Code, click on the Extensions tab, search and install Code Runner by Jun Han

Step 3. In the C/C++ Configurations. Make sure the Compiler Path has c:/MinGW/bin/gcc.exe selected. screenshot 2

You can get to it by opening Command Pallet (ctrl+shift+p) typing in C/++: Select a Configuration.. then select Edit Configurations (UI)

๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 64008232 โ€บ how-to-execute-a-c-program-in-vs-code
How to execute a C program in VS Code - Stack Overflow
link your compiler to vs code. if you are using c, it should be gcc or some other fork. to use the compiler just open the terminal, go to gcc or what your compiler name is, and then run it in terminal(if you right click on code)
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Run C/C++ in Visual Studio Code (Complete Setup) - YouTube
In this video, I will show you How to Run C and C++ in Visual Studio Code โ€” breaking it down step by step so you can follow along and use it in your own pro...
Published: September 12, 2026
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 65598881 โ€บ how-to-compile-c-program-in-visual-studio-code
How to compile C program in Visual Studio Code? - Stack Overflow
Choose your newly installed compiler (GCC or Clang) from the prompt. It will compile the code and print "Hello world!" in the terminal at the bottom
๐ŸŒ
DEV Community
dev.to โ€บ haythammostafa โ€บ run-c-code-in-visual-studio-code-2j86
Run C Code in Visual Studio Code - DEV Community
July 3, 2023 - In the MinGW Installation Manager, we need to check the Mingw32-base package, Ming32-gcc-g++ package and Ming32-gcc-objc package to run and compile the C/ C++ program in the visual studio code. After selecting the checkbox, click on the Installation tab (at the top left corner of the dialog box). 9) Click on Apply Changes to set the package's installation in MinGW ... b. In the System Variables Path click on the Edit button, then click on the New button and then paste the C:\MinGW\bin path; after that, click OK ยท 13) Check C and C++ compilers again now, Open your terminal and run:
๐ŸŒ
YouTube
youtube.com โ€บ amit thinks
How to run C program on Visual Studio Code - YouTube
Learn how to run a C program on Visual Studio Code. VS Code is a free source code editor developed by Microsoft.Install Visual Studio Code: https://youtu.be/...
Published: October 2, 2020
Views: 281K
๐ŸŒ
Medium
medium.com โ€บ @aleksej.gudkov โ€บ how-to-run-c-code-in-vs-code-on-mac-473980c24679
How to Run C Code in VS Code on Mac | by UATeam | Medium
November 24, 2024 - Open the integrated terminal in VS Code (Ctrl+`` ). Navigate to the directory containing your code. ... Hello, World! Running C code in VS Code on a Mac is straightforward with the right setup.
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Run program In VS Code Terminal | VS Code Terminal not working C/C++ - YouTube
PROGRAMS NOT RUNNING PROPERLY ON VS CODE (EASY FIX) | 100% WORKINGPlease Subscribe To My Channel...So that next time someone asks you what's exclusive you'd ...
Published: March 23, 2021
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Run C Program in Visual Studio Code - YouTube
Buy me a Coffee ๐Ÿฅฐ : https://www.buymeacoffee.com/yaminshakilThanks For Watching. I can Make Website for you : My Email : yaminshakil7@gmail.comWebsite Ad...
Published: April 4, 2025
๐ŸŒ
Unstop
unstop.com โ€บ home โ€บ blog โ€บ how to run c program | step-by-step guide + detailed examples
How To Run C Program | Step-by-Step Guide + Detailed Examples
September 16, 2024 - Note that the C language is platform-dependent and must be compiled into object code by a compiler for execution of C programs. Wondering how? In this article, we will discuss everything you need to know about how to run a C program. We have given step-by-step instructions on how to run/ execute a C program with and without an IDE and in the Visual Studio code editor (e.g., VSCode).
๐ŸŒ
YouTube
youtube.com โ€บ bytepage
How to run code in terminal in VS code | Visual studio Code - YouTube
In this video, we'll be exploring the topic of terminal execution in VS Code. We'll be looking at how to run code in the terminal, and how to use different t...
Published: July 28, 2023
Views: 333K
๐ŸŒ
Medium
ludwiguer.medium.com โ€บ configure-visual-studio-code-to-compile-and-run-c-c-3cef24b4f690
Configure Visual Studio Code to compile and run C/C++ | by Luis Guerrero | Medium
April 6, 2020 - Until here everything seems fine, but since the OUTPUT tab is read-only, we cannot interact with our code if we need to. To be able to do so, we need to tell the extension Code Runner to run our program in the TERMINAL instead of the OUTPUT tab ...