![]() |
VOOZH | about |
Compiling and running C programs on Windows requires a proper C compiler and access to the system terminal. With MinGW (a Windows-friendly version of the GCC compiler), users can easily convert their C source code into executable files using the Command Prompt. This article will guide you through installing MinGW, configuring the environment, and compiling C programs directly from the terminal.
Key Highlights:
.c files into executablesTo compile and run C programs on Windows, you need a compiler and a terminal. MinGW (Minimalist GNU for Windows) provides an easy-to-install GCC compiler that works perfectly with Command Prompt (CMD). Once set up, you can compile any .c file into an executable using simple commands.
Below is a step-by-step guide to install MinGW, configure system paths, and compile/run C programs effortlessly.
Before running C programs, install a compiler that converts C source code into machine code.
In MinGW Installation Manager, select the following packages:
mingw32-basemingw-gcc-g++Adding MinGW to the PATH allows you to use gcc from any folder in CMD.
- gcc --version
If MinGW is installed correctly, the GCC version will appear.
Use the cd command to go to the folder containing your .c file
Use this syntax to compile your program:
gcc filename.c -o filename.exe
Explanation:
filename.c β your C source file-o filename.exe β creates an executable output fileExample:
gcc hello.c -o hello.exe
Finally, run your program with:
Example: hello.exe
Your C program output will now appear in the terminal.
It is Armstrong No.
Also Read