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
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ what tools do you use with visual studio code to run c code ?
r/C_Programming on Reddit: What tools do you use with Visual studio code to run C code ?
July 29, 2022 -

I followed what is said on this blog post, it takes so much time to run(or build) and sometimes just doesn't.

i've been using CodeBlocks before but didn't get comfortable with it i just don't like, it would be great if i can use VSC.

Edit: i use Windows.

c With visual studio code Nov 4, 2021
r/C_Programming
5y ago
Using Visual Studio 2022 to learn C Nov 27, 2021
r/C_Programming
4y ago
how do i run c++ on Visual studio code? Sep 30, 2022
r/learnprogramming
4y ago
More results from reddit.com
๐ŸŒ
Medium
medium.com โ€บ @ochwada โ€บ c-programing-setup-in-visual-studio-code-bd4cb60e58ff
C Programming โ€” Setup in Visual Studio Code | by Ochwada | Medium
November 16, 2024 - No Built-in Exception Handling: Unlike many modern languages, C does not have built-in exception handling (like try/catch blocks), making error handling more manual and detailed. Visual Studio Code: Download and install Visual Studio Code.
Discussions

How to compile C program in Visual Studio Code? - Stack Overflow
Now I would like to run the program, but can't find a way. There's no "run" or "build" option anywhere, and if I start the debugging and choose the debugger then I got a new tab named "settings.json" with a couple of brackets waiting for me to write something. More on stackoverflow.com
๐ŸŒ stackoverflow.com
guys who can explain me how to install C in VS code?
refer to the vscode documentation: https://code.visualstudio.com/docs/languages/cpp More on reddit.com
๐ŸŒ r/C_Programming
17
0
October 31, 2025
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 try to run the program, it just keeps telling me that I need to install an extension environment for C, because VSC doesn't come with ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
C in Visual Studio Code
Why downloading plugins for CSS and HTML? To compile C all you need is an compiler. There is a tutorial which explains everything you need for a simple hello world program: Configure VS Code for Clang/LLVM on macOS (visualstudio.com) More on reddit.com
๐ŸŒ r/C_Programming
14
1
April 26, 2024
Top answer
1 of 1
5

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 - Also read: C Programming Books for Beginners and Advanced ยท Visual Studio Code provides a versatile and efficient environment for C programming across different operating systems.
๐ŸŒ
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 - If you get the version number, then the compiler is already installed on your system, otherwise you need to proceed with the next step. 2) Download the MinGW-w64 Compiler Go to the https://sourceforge.net/projects/mingw link ยท 3) MinGW software has been successfully downloaded. ... 8) As we click on the Continue, it shows the below image. 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.
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ languages โ€บ cpp
C/C++ for Visual Studio Code
November 3, 2021 - A year of VS Code, wrapped. Explore the highlights. Dismiss this update ... C/C++ support for Visual Studio Code is provided by a Microsoft C/C++ extension to enable cross-platform C and C++ development on Windows, Linux, and macOS.
๐ŸŒ
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 - Simply open VS Code/VS Code Insiders, open any folder, and create any file with the extension .c for the C file and .cpp for the C++ file. After writing your code, you can run the code directly using the play button you'll find in the upper ...
Find elsewhere
๐ŸŒ
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 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags.
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ guys who can explain me how to install c in vs code?
r/C_Programming on Reddit: guys who can explain me how to install C in VS code?
October 31, 2025 - You can then use the Visual C compiler and CMake from VS Code or Visual Studio (your choice, you can switch if you like one better). Visual Studio includes a C compiler. You can install the compiler by itself without Visual Studio, but I strongly, ...
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)

๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Setup C/C++ in VS Code [Updated 2025] Complete Installation with example | Amit Thinks - YouTube
Learn how to setup and run C/C++ on VS Code. We will also run an example C file after the setup.C Tutorial (English): https://youtu.be/CobHIiQXMtQC Tutorial ...
Published: January 15, 2025
๐ŸŒ
YouTube
youtube.com โ€บ code bear
How to Set up Visual Studio Code for C and C++ Programming - YouTube
In this video ill show you how to setup visual studio code for c/c++ programming on windows , we will first download and Install C/C++ toolset like mingw wh...
Published: November 27, 2022
Views: 1M
๐ŸŒ
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...
๐ŸŒ
YouTube
youtube.com โ€บ coding wallah sir
How to install C & C++ in Visual Studio Code | Setup VS Code for C & C++ Programmers [ 2024 ] ๐Ÿš€ - YouTube
how to install c in visual studio codehow to install c++ in visual studio code windows 11visual studio code, vs code, c programmingC++ Tutorial One Shot - ht...
Published: April 26, 2024
Views: 150K
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ shows โ€บ visual-studio-toolbox โ€บ c-programming-with-visual-studio-code
C++ Programming with Visual Studio Code | Microsoft Learn
January 4, 2018 - In this episode, Robert is joined by Rong Lu, who shows the C/C++ support in Visual Studio Code provided by the Microsoft C/C++ extension. The focus of the extension is code editing, navigation, and debugging support. Rong shows IntelliSense, formatting and navigating code, Peek and Go to definition and then building and debugging.
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ c in visual studio code
r/C_Programming on Reddit: C in Visual Studio Code
April 26, 2024 -

I want to practice C in Visual Studio Code (mac). I was already prompted to download a bunch of add ons for C and other languages such as CSS and HTML.

I wrote my code and tried to run the executable in the terminal but apparently I need to download the "command line developer tools" package. I had to stop myself because it requires a whopping 15.6 GB of disk space while the program itself is only 580 mb. How can this be if there are sandbox programs which you can code in on your browser? As far as I understood people have been coding in c since a hard drive of 512 mb was considered big...

๐ŸŒ
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 - Now our program will run in the TERMINAL tab and we will be able to enter data if we need to. And thatโ€™s it, following these steps you will be able to compile and run code in C/C++ using Visual Studio Code. ... Product-focused Software Engineer with more than 13 years of experience delivering ...
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ c development using vscode
r/C_Programming on Reddit: C development using VScode
September 13, 2017 -

Im a beginner in programming and I d lime to use vscode for c programming the problem is I installed C/c++ plugin for vscode and i imstalled a compiler but vscode never runs my c code help..

๐ŸŒ
Visual Studio Marketplace
marketplace.visualstudio.com โ€บ items
C/C++ - Visual Studio Marketplace
Extension for Visual Studio Code - C/C++ IntelliSense, debugging, and code browsing.
๐ŸŒ
Medium
medium.com โ€บ @tarangnpatel โ€บ visual-studio-code-c-programming-on-linux-c990b9705314
Visual Studio Code & C programming on Linux | by Tarang Patel | Medium
August 9, 2019 - VSCode needs special extension to provide rich code editing options for C. The extension is developed by Microsoft. Click on Extensions icon on the sidebar and search for โ€œcโ€. The first search result, โ€œc/c++โ€ by Microsoft is the popular ...