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
Next, verify that the developer command prompt is set up correctly. In the command prompt window, enter cl (or CL, case doesn't matter for the compiler name, but it does matter for compiler options).
🌐
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 in windows
This is not a language problem, rather an IDE problem. I know VSCode has pretty bad support for C, and Visual Studio is quite massive, so that probably wouldn't work. Code::Blocks is a very lightweight IDE for C and C++, you could try that. More on reddit.com
🌐 r/C_Programming
22
1
August 19, 2021
🌐
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 - ... If MinGW is installed correctly, the GCC version will appear. Use the cd command to go to the folder containing your .c file · Type "cd C:\MyPrograms" , Click Enter button. ... Your C program output will now appear in the terminal.
🌐
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 - Type “cl” followed by the filename of your C program and press Enter. Type the executable name and press Enter to run the program. ... Go to https://visualstudio.microsoft.com/downloads in a web browser.
🌐
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
🌐
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 ...
Find elsewhere
🌐
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 - Read more – How to download, install and configure CodeBlocks with C compiler in Windows. Open notepad. Hit windows button and type notepad in it. Alternatively, hit Win + R, type notepad and hit enter to open notepad. Type C source code in notepad. For now do not care about what you are typing just copy paste the source code. We will have in depth discussion on C program structure later.
🌐
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
🌐
GUVI
guvi.in › hub › c-tutorial › compile-and-run-c-program
How to Compile and Run C Program?
Step 2: Write a Hello World program that we created in the previous article · Step 3: Click on Compile menu and then on Compile option, or press the keys and press Alt + F9 to compile the code.
🌐
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
[ltoma@dover:~/cs3225]$ cd startup/ ... to the owner, and readable only to everybody else. The file is not executable. run the compiler (gcc) to compile your code into an executable you can run....
🌐
GeeksforGeeks
geeksforgeeks.org › compile-and-run-c-program-in-terminal
How to Compile and Run C program in Terminal?
Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
🌐
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...
🌐
Wikihow
wikihow.com › computers and electronics › software › programming › c programming languages › how to compile a c program using the gnu compiler (gcc)
How to Compile a C Program Using the GNU Compiler (GCC)
February 19, 2026 - Type cmd in the search bar next to the Start menu. Right-click Command Prompt in the search results, then select Run as Administrator. Click Yes to allow changes. ... Go to the folder where your source code is saved. For example, if your source code file called helloworld.c is located in C:\Source\Programs, type cd C:\Source\Programs and press Enter.
🌐
Colby College
cs.colby.edu › maxwell › courses › tutorials › writingCprograms
Tutorial: C Program
To compile a C program using the command line, you can use the following. ... The way to parse the above is that gcc is the command, -o is a flag that says the next argument is what the executable should be called. The file to be compiled is next (myfile.c) and the last argument -lm is the -l flag, which links in a library, and m is the math library.
🌐
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 - After downloading a C compiler and typing the C source code in any text editor, navigate to the location of the file in cmd. Type 'gcc filename.c' to create the executable file. And finally, execute the a.exe file to get the output.