PDF download Download Article
Turn your C files into programs you can run
PDF download Download Article

If you've written or downloaded some C code on your Windows PC, you'll need to compile the code to turn it into a program you can run. You can easily do so using the developer command prompt for Visual Studio, which is free to download for personal use. The developer command prompt works just like the standard command prompt, but has extra developer commands, such as the ability to compile and run C programs. This wikiHow article teaches you how to compile and run C programs using the developer command line.

Quick Steps

  1. Download and install Visual Studio Desktop Development with C++
  2. Write your C program using a text program such as Notepad.
  3. Save the file as a “.c” file.
  4. Open the Developer Command Prompt as an administrator.
  5. Type “cl” followed by the filename of your C program and press Enter .
  6. Type the executable name and press Enter to run the program.
Part 1
Part 1 of 3:

Installing Visual Studio

PDF download Download Article
  1. Go to https://visualstudio.microsoft.com/downloads in a web browser. Visual Studio not only contains an IDE that allows you to write and compile C programs, but it also contains a Developer Command Prompt that allows you to compile C programs. The Developer Command Prompt works just like the regular Windows Command Prompt, except it has environment variables that allow you to run commands to compile C programs.
  2. If you are just learning how to write a program or using it for personal use, click Free Download below “Community.” This is the free version of Visual Studio. If you are working for a small team, you can click Free Trial below “Professional.” If you work for a large company, you can click Free Trial below “Enterprise.” This will download the Visual Studio installer.
    Advertisement
  3. You can find it in your downloads folder by default. This will launch the Visual Studio installer. Once the installer launches, it will inform you that you need to set up a few things to configure the installation. Click Continue to proceed.
  4. Installing Desktop Development with C++ will install the components needed to write and compile C++ and C programs. You can also install any other languages you are interested in working on (i.e., Python development). [1]
    • Depending on what you are interested in working on, you may want to install other C++ development workloads, such as Mobile development with C++ , Game development with C++ , or WinUI application development.
    • Additionally, you can click the Individual Components tab at the top and check individual boxes next to the tools you want to install, such as C++/CLI support.
  5. This will begin installing the development workloads you selected. This may take a while.
  6. Advertisement
Part 2
Part 2 of 3:

Making a C Program

PDF download Download Article
  1. You can use a basic text program such as Notepad to write basic C programs. Notepad comes pre-installed on Windows. You can find Notepad in the Windows Start menu.
    • Alternatively, you can use a program such as Notepad++ or an integrated development environment such as Eclipse to write C programs. These programs have tools to assist you with writing code.
  2. You can write your entire C program in Notepad . If you have no programming experience, you may want to take some time to learn. You can find plenty of tutorials online with examples of basic C programs. [2]
  3. Use the following steps to do so:
    • Click File in the menu bar at the top.
    • Click Save as in the drop-down menu.
    • Select All files next to “Save as type.”
    • Enter a filename for the file.
    • Add the extension “.c” at the end of the filename.
    • Click Save .
  4. Advertisement
Part 3
Part 3 of 3:

Compiling and Running a C Program

PDF download Download Article
  1. Visual Studio installs a Developer Command Prompt that works just like CMD, but allows you to execute developer commands. Use the following steps to open the Developer Command Prompt.
    • Click the Windows Start button.
    • Type developer command prompt
    • Right-click Developer Command Prompt for VS .
    • Click Run as administrator .
  2. You can change directories using the “CD” command. Type cd followed by the path to the location of your C program and press Enter . For example; cd C:\Users\[username]\Documents\C Programs\Hello .
  3. For example, cl hello.c . This will compile the program and output an executable (.exe) file.
    • You can compile more than one file at a time. To do so, enter each filename after the “cl” command separated by a space. For example, cl file1.c file2.c file3.c
    • If you want to change the name of the executable file, type /out: followed by the name you want to give the executable file at the end of the command. For example, cl hello.c /out:helloworld.exe
  4. To run the executable file in the command line, simply type the filename of the executable file (i.e., “helloworld.exe”) and press Enter . This will run the executable file.
  5. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Tips

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

      About This Article

      Thanks to all authors for creating a page that has been read 325,958 times.

      Is this article up to date?

      Advertisement