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
Running c program from command line in one step? - Stack Overflow
I just got started writing some C programs. To start with I was just running them through VS code. Nice and easy, I just had to press a button and bam, there it was. But now I need to pass files as More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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
๐ŸŒ
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.
๐ŸŒ
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.
๐ŸŒ
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.