One easy way to do this is to get a standalone build of MinGW-w64 for Windows from https://winlibs.com/.

This will provide you with all the tools you need to compile and link Windows programs.

The command will be gcc instead of cc, but to run it, you should specify its complete path. When the download is extracted you can find it under mingw64\bin\gcc.exe. Or you can add it to the PATH environment variable (but I don't recommend this).

There are examples on how to use it at https://winlibs.com/.

If you are a beginner it is recommended to use a GUI like VSCode or Code::Blocks, so you won't need command line actions to compile and link your code, and you can even debug your code if you need to.

Answer from Brecht Sanders 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
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise>cl Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x86 Copyright (C) Microsoft Corporation. All rights reserved. usage: cl [ option... ] filename... [ /link linkoption... ] There might be differences in the current directory or version numbers, depending on the version of Visual Studio and any updates installed. If the preceding output is similar to what you see, then you're ready to build C or C++ programs at the command line.
🌐
Edureka
edureka.co › blog › how-to-compile-c-program-in-command-prompt
How to Compile & Run a C Program in Command Prompt?
July 23, 2024 - You’ve just executed a program via the Command Prompt!. Create a text file with a text editor. For example with nano: ... Save this file as hello.c. ... Compile: gcc filename.c -o outputname Run: ./outputname.
Discussions

assembly - How to compile C programs using cc command in cmd - Stack Overflow
I'd like to know how I can use cc compiler/assembler from cmd (I am on windows) to compile/assemble C programs. I tried running the cc command on a .c file with MinGW and MSYS2 installed, and it di... More on stackoverflow.com
🌐 stackoverflow.com
Compiling C-code from the Command Prompt in Windows? - Stack Overflow
I want to compile C code from the Command Prompt in Windows. I have added the environment variable to the PATH and I can compile .cs files with: csc app.cs That's OK, but how do I compile app.c? More on stackoverflow.com
🌐 stackoverflow.com
windows - How to compile C program on command line using MinGW? - Stack Overflow
What command does one have to enter at the command line in Windows 7 to compile a basic C program? Like I am literally wondering what you type in the command prompt, to compile a .c file. I tried... More on stackoverflow.com
🌐 stackoverflow.com
How to run c++ files in the command line?
You need to compile first. For single-file compilation, you can use the command g++ -Wall your_source_file.cpp -o name_of_the_exe (if you are on Windows, add .exe to the output name). You can also pass in multiple source files (header files not needed) in a single command (e.g: g++ -Wall mylib.cpp main.cpp -o my_program.exe), but it is time consuming if you have many files. Thus, for more realistic projects, usually you need to setup a build system. It may be Make if it is simple, or CMake/Meson if you want a full-fledged build system. In that case, you need to invoke the commands corresponding to your build system. After you have compiled the program, type its name to the terminal to run it. Here is how I do it on Linux: https://i.imgur.com/g8hvQCk.png , you don't need the ./ if you are using cmd. Note: The -Wall is not required, but is strongly recommended, it is for enabling warnings. Usually when your code has warnings, there is something wrong with it, so try to understand and fix it properly* even when warnings do not prevent you from successfully compiling your program. * Mindlessly fixing warnings is more harmful than not fixing them. You may alter the program behavior when you try to get rid of the warnings without thinking about the code meaning. More on reddit.com
🌐 r/cpp_questions
13
5
April 18, 2021
🌐
Wikihow
wikihow.com › computers and electronics › operating systems › windows › simple ways to run c program in command prompt
How to Run a C Program Using Developer Command Prompt
March 25, 2025 - For example, cl hello.c /out:helloworld.exe ... Run the executable file. To run the executable file in the command line, simply type the filename of the executable file (i.e., “helloworld.exe”) and press Enter.
🌐
Codeforwin
codeforwin.org › home › how to compile and run c program using command line in windows
How to compile and run C program using command line in Windows - Codeforwin
July 20, 2025 - Compiling C program from IDE is fairly simple. In this post I will explain how to compile and run C program using command line and GCC compiler in windows.
🌐
GeeksforGeeks
geeksforgeeks.org › techtips › how-to-compile-and-run-c-program-in-terminal
How to Compile and Run C program in Terminal - GeeksforGeeks
December 5, 2025 - Press Windows Key, search cmd. Right-click → Run as Administrator. ... If MinGW is installed correctly, the GCC version will appear. Use the cd command to go to the folder containing your .c file
🌐
Christopher Siu
users.csc.calpoly.edu › ~phatalsk › references › howToCompileAndRunCProgramsFromCommandLine.html
How To Compile and Run C Programs From the Command Line
For example, assumming you have mySource1.c, mySource2.c, and mySource3.c, the command to compile them into a single program would be: gcc -ansi pedantic -Wall -Werror -lm mySource1.c mySource2.c mySource3.c
Find elsewhere
🌐
Quora
quora.com › How-do-I-compile-and-run-C-programs-in-the-command-line-using-notepad-in-Windows
How to compile and run C programs in the command line using notepad in Windows - Quora
Answer (1 of 12): To learn any programming language ,it is better to start with notepad instead of using any IDE to write and execute programs. You can use TDM-GCC MinGW compiler. to download it use the link below: TDM-GCC MinGW Compiler 1.Now how to install TDM-GCC MinGW:- after download is ...
🌐
Linux Hint
linuxhint.com › compile-and-run-c-program-command-prompt
How to Compile and Run a C Program in Command Prompt – Linux Hint
Step 2: Then run the following command in the Command Prompt to confirm gcc is installed on your system. ... If gcc is not found, you have to download and install a gcc compiler. Follow the guide here if gcc isn’t installed. Step 3: Now write a C program as well as save it to your computer.
🌐
YouTube
youtube.com › bro code
C compile and run a C program with cmd 🏗️ (optional video) - YouTube
compile and run a c file with command prompt#C #compile #run⭐️Time Stamps⭐️(00:00:00) intro(00:00:17) Step 0. check if you have a gcc compiler(00:00:34) Step...
Published   August 21, 2021
Views   108K
🌐
Tildesites
tildesites.bowdoin.edu › ~ltoma › teaching › cs3225-GIS › fall16 › Lectures › basics.html
Compiling and running a C program from the terminal
bid19628:~ ltoma$ cd Desktop/ bid19628:Desktop ltoma$ mkdir local-cs3225 bid19628:Desktop ltoma$ cd local-cs3225 bid19628:local-cs3225 ltoma$ mkdir startup/ bid19628:startup ltoma$cd startup Now you should see a new empty folder called local-cs3225 on the Desktop. Start "Aquamacs" or "Xemacs". Start typing your code. Save this program as "~/Desktop/local-cs3225/startup/hello.c". Compile and run as above.
🌐
Quora
quora.com › How-do-I-compile-a-C-program-in-a-command-prompt
How to compile a C program in a command prompt - Quora
Answer: it will depend the compiler you are using for example in gcc, you just do gcc with a few other options and you can get them by doing gcc -h or gcc -? can be - or / depending on the OS. but you do not necesarily have Gcc you can have a lot of others and each will have its own s...
🌐
GUVI
guvi.in › hub › c-tutorial › compile-and-run-c-program
How to Compile and Run C Program?
Or, you can use any text editor to edit the program files and download the C compiler separately and then run the C program using the command line.
🌐
Colby College
cs.colby.edu › maxwell › courses › tutorials › writingCprograms
Tutorial: C Program
This tutorial is for those of you who don't want to deal with the menus of an IDE or the need to build a multi-story project for every little program. The following gives you an introduction to writing, compiling, and linking programs from the command line using the gcc C compiler.
🌐
YouTube
youtube.com › watch
How to Compile and Run a C Program from Command Prompt in Windows Computer - YouTube
In this C Programming Language tutorial, we will show you how to compile and run a C program from the command prompt on a Windows computer. The video covers ...
Published   February 19, 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 - To check whether the C compiler is being recognized, open cmd and type gcc. If the following message is displayed, then the compiler is correctly installed. The next step is to open the text editor of your choice and type in the C source code to be executed, and save it. In the image below, we have saved the file as firstprogram.c. To run the file, open the command prompt window.
🌐
GitHub
github.com › MicrosoftDocs › cpp-docs › blob › main › docs › build › walkthrough-compile-a-c-program-on-the-command-line.md
cpp-docs/docs/build/walkthrough-compile-a-c-program-on-the-command-line.md at main · MicrosoftDocs/cpp-docs
This guide explains how to create a basic Hello, World-style C program by using a text editor, and then compile it on the command line. If you'd rather work in C++ on the command line, see Walkthrough: Compiling a Native C++ Program on the Command Line.
Author   MicrosoftDocs