How to Run C Program in Command Prompt

This article was reviewed by Stan Kats and by wikiHow staff writer, Nicole Levine, MFA. Stan Kats is the COO and Chief Technologist for The STG IT Consulting Group in West Hollywood, California. Stan provides comprehensive technology & cybersecurity solutions to businesses through managed IT services, and for individuals through his consumer service business, Stan's Tech Garage. Stan has over 7 years of cybersecurity experience, holding senior positions in information security at General Motors, AIG, and Aramark over his career. Stan received a BA in International Relations from The University of Southern California.

This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.

This article has been viewed 308,279 times.

If you've written or downloaded some C code on your Windows PC, you'll need to compile the code to turn it into an program you can run. This simple wikiHow tutorial will walk you through compiling and running a C program from the Windows command prompt using MinGW, an easy-to-install version of the GCC compiler.

Step 1 Install MinGW, a simple C compiler.

Fair Use (screenshot)
\n">

Step 2 Add the compiler

Fair Use (screenshot)
\n"> Advertisement

Step 3 Open a Command.

Fair Use (screenshot)
\n">

Step 4 Use the cd command to go to the directory where your C <a href=program is saved." width="460" height="345" />

Fair Use (screenshot)
\n">

Use the cd command to go to the directory where your C program is saved. For example, if the program you want to compile is in C:\MyPrograms, type cd C:\MyPrograms and press Enter.

Step 5 Run the gcc command to compile your C program.

Fair Use (screenshot)
\n">

Step 6 Type <a href=the name of your new program and press ↵ Enter." width="460" height="346" />

Fair Use (screenshot)
\n">

Type the name of your new program and press ↵ Enter . For example, if you created a program called hello.exe , you can type hello or hello.exe . This runs your C program from the command prompt. [5] X Research source

Advertisement

Expert Q&A

Ask a Question 200 characters left Include your email address to get a message when this question is answered. Advertisement

Tips

Submit a Tip All tip submissions are carefully reviewed before being published Please provide your name and last initial Thanks for submitting a tip for review!

You Might Also Like

Take a Screenshot in Microsoft Windows

How to Take a Screenshot on a Windows PC: 8 Simple Tricks

Check Your Windows Version

Check Your Windows Version

Change Your Desktop Background in Windows

5 Quick Ways to Change Your Desktop Wallpaper on Windows

Check Mouse Sensitivity (Dpi) on PC or Mac

How to Check Your Mouse DPI on Windows & Mac

Enter BIOS

How to Access the BIOS on Any PC: Guide + Troubleshooting

Check Your Windows Product Key

How to Find Your Windows Product Key

Get to the Boot Menu on Windows

4 Easy Ways to Access the Boot Options Menu in Windows

Install FFmpeg on Windows

Easily Download and Install FFmpeg on a Windows PC

Start Windows in Safe Mode

How to Start Windows in Safe Mode: 6 Easy Options

Change the Windows Taskbar Position

How to Change the Windows Taskbar Position: 2 Easy Methods

Automatically Shut Down Your Computer at a Specified Time

Automatically Shut Down Your Computer at a Specified Time

Turn Off S Mode in Windows 11

2 Ways to Turn Off S Mode on a Windows 11 PC

How Do You Hyperlink on Canva

How Do You Hyperlink on Canva — A Quick Guide

Change a Computer

3 Ways to Change a Computer's Mac Address in Windows