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.

Answer from GoWiser on Stack Overflow
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ cpp โ€บ build โ€บ walkthrough-compile-a-c-program-on-the-command-line
Compile a C Program on the Command Line | Microsoft Learn
If you installed Microsoft Visual C++ Build Tools 2015 on Windows 10 or later, open the Start menu, and choose All apps. Then, scroll down and open the Visual C++ Build Tools folder.
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)

Discussions

What tools do you use with Visual studio code to run C code ?
Windows has always been a pain to me since I have a potato PC and I can't run visual studio. In your case, you either Use a fully blown ready to use (bloated) IDE, like Visual Studio, CodeBlocks and CLion (Not suitable for potato PCs/Laptops). Spend some time to configure/customize your code editor, E.G. vscode or vim (or neovim). In my experience, no matter which editor you use, having a C++ installation of visual studio saves some time of configuring the PATH and toolchain directory and stuff (especially if you're a beginner). More on reddit.com
๐ŸŒ r/C_Programming
55
15
July 29, 2022
Hi How to run a c program on visual studio community 2022?
Hi, I am a new learner, I am trying to get output from a code but the Local Window Debugger button is not there, I have tried almost every solution I could find but the solution was not there anymore for example one solution told me to go toโ€ฆ More on learn.microsoft.com
๐ŸŒ learn.microsoft.com
1
0
April 28, 2024
C programming in Visual Studio - Stack Overflow
Can I use Visual Studio to learn C programming? In the new project menu I can choose between Visual Basic, Visual C#, Visual C++, Visual F# and others but I don't see "C" or "Visual C". More on stackoverflow.com
๐ŸŒ stackoverflow.com
Easiest way to set up C compiler on Windows 10 (if you use Visual Studio Code)?
The simplest way is to download and install "Build Tools for Visual Studio 2022", which includes the compiler (MSVC) and its command prompt. After that you open the compiler's command prompt and compile your code using the command: cl filename.c This will generate the file: filename.exe You can run it by simply executing: filename That's it! More on reddit.com
๐ŸŒ r/C_Programming
29
27
March 8, 2023
๐ŸŒ
Visual Studio Code
code.visualstudio.com โ€บ docs โ€บ languages โ€บ cpp
C/C++ for Visual Studio Code
November 3, 2021 - Select the Extensions view icon on the Activity Bar or use the keyboard shortcut (โ‡งโŒ˜X (Windows, Linux Ctrl+Shift+X)). Search for 'C++'. Select Install. C++ is a compiled language meaning your program's source code must be translated (compiled) before it can be run on your computer.
๐ŸŒ
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 - If you wish to run it without debugging, then press Ctrl + F5. The Visual Studio is a code editor which works like IDE and functions with any compiler that is installed on the system.
๐ŸŒ
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 - Before approaching the process of running your first C or C++ code on Visual Studio Code, let me guide you through the process and get it all set up based on the operating system you are using on your computer.
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ answers โ€บ questions โ€บ 1661018 โ€บ hi-how-to-run-a-c-program-on-visual-studio-communi
Hi How to run a c program on visual studio community 2022? - Microsoft Q&A
April 28, 2024 - If the code you have is from an existing project, try to get the whole project and open the project(File => Open => Project/Solution) in Visual Studio then run it.
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ watch
How to Run C Program in Visual Studio Code | Install VS Code on Windows 10 - YouTube
Visual Studio Code Installation Link.๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡https://code.visualstudio.com/downloadMinGw Compiler Installation Link.๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡https://sourceforge.net/projects/ming...
Published ย  July 6, 2021
๐ŸŒ
PW Skills
pwskills.com โ€บ blog โ€บ cpp โ€บ can i use c programming in vs code? explained in detail!
Can I Use C Programming In VS Code? Explained In Detail!
November 4, 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.
๐ŸŒ
Javatpoint
javatpoint.com โ€บ how-to-run-a-c-program-in-visual-studio-code
How to run a C program in Visual Studio Code - javatpoint
How to run a C program in Visual Studio Code with Tutorial, C language with programming examples for beginners and professionals covering concepts, c pointers, c structures, c union, c strings etc.
๐ŸŒ
Medium
mhzarif.medium.com โ€บ how-to-setup-vs-code-for-c-programming-inwindows-10-7eee23f37ea6
How to setup VS Code for c programming in Windows 10 | by Muhammad Hasan Zarif | Medium
December 7, 2023 - 2. Open the integrated terminal in VS Code (`Ctrl+` ` ` `) and navigate to the folder containing your C file. 3. Run the compiled program using `./<your_program_name>`. Now, you should have a working setup for C programming in Visual Studio ...
๐ŸŒ
Reddit
reddit.com โ€บ r/c_programming โ€บ easiest way to set up c compiler on windows 10 (if you use visual studio code)?
r/C_Programming on Reddit: Easiest way to set up C compiler on Windows 10 (if you use Visual Studio Code)?
March 8, 2023 -

I've been learning C and playing around with it for a couple of months already.

I'm following CS50 course and first half of the course is almost entirely in C.

That being said, I only used their online codespaces so far, - and for my own personal practice, I used online complilers such as https://www.programiz.com/c-programming/online-compiler/

and https://www.onlinegdb.com/online_c_compiler .

This allowed me to focus on coding and not worry about compiling. I've made some stuff already, entirely using these tools.

However, now arrives the time that I need my own compiler on local machine.

The main reason is that I want to start practicing working with files on my own hard disk, and also using libraries outside of what these tools offer, such as conio.h.

I already tried to google how to set-up a compiler in Windows, but I've bumped into many hoops and obstacles and it's not (at least for me) as straightforward as it might seem.

So I'm asking you for help to set up my own coding environment for C in Windows, where I could compile the files (ideally with make too, and not just clang), where I could include external libraries, where I could work with files on my own HDD, etc... And ideally, where I could even turn these files into classical .exe files.

Thanks!

EDIT: Resolved:

Installing Visual Studio 2022 Community with included tools for C++, and then running Developer Command Prompt allowed me to compile C files by using command: cl filename.c which returns exe file, filename.exe . This exe file can be started by simply executing filename in command prompt or even from Windows by simply double clicking on its icon, like any other file. Thanks for all the responses, especially to RidderHaddock and _mutaz_ who gave me best directions.

๐ŸŒ
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 - Install C/C++ Extension: Open VS Code, go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or press Ctrl+Shift+X, and search for "C/C++". Install the official C/C++ extension provided by ...
๐ŸŒ
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
I installed VSC and wrote this program #include int main( void ) { printf("Hello world!"); } Then I installed a C/C++ debugger and I saved the file on the desktop as...
๐ŸŒ
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.
๐ŸŒ
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.