banner



How To Compile And Run C Program In Windows 7

Download Article

Download Article

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

Steps

  1. i

    Install MinGW, a simple C compiler. If you haven't already done so, y'all'll need to install a C compiler on your PC to compile the C program. Compiling the C code will plough the code into an executable C programme. MinGW is one of the easiest options to install for Windows:

    • Download MinGW from https://sourceforge.net/projects/mingw.
    • Double-click the downloaded file and follow the on-screen instructions to prepare the installation.
    • When you become to the MinGW Installation Managing director window, you'll encounter several packages in the upper-correct panel.
    • Check the boxes next to "mingw32-base" and "mingw-gcc-g++."
    • Click the Installation menu and select Apply Changes.
    • Click Apply.
  2. 2

    Add the compiler'south path to your system environment variables. This pace makes it easier to run the compiler from the command prompt, as you won't have to enter the full path to the GCC program.

    • Press the Windows key and type environment. Click Edit the arrangement environment variables in the search results.
    • Click the Environment Variables… button.
    • Select the "Path" selection under "System variables" and click Edit…
    • Click New.
    • Blazon C:\MinGW\bin and click OK.
    • Click OK and OK again.

    Advertizement

  3. three

    Open up a Command Prompt window as an ambassador. To do this, printing the Windows key, blazon cmd, correct-click Control Prompt, so select Run equally Administrator.

    • One time the prompt window is open, double-bank check that the compiler installed properly (and that the environment variables are set) by running the command gcc -- version at the prompt.
    • If you already had a command prompt window open up, close information technology and open another so the path you added
  4. four

    Use the cd command to become 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.

  5. 5

    Run the gcc control to compile your C program. The syntax you'll use is gcc filename.c -o filename.exe. This compiles the program and makes it executable.

    • Replace filename.c with the name of the file containing your C code, and filename.exe with the name you want to requite the compiled program.
    • Make sure you give the compiled program a name that ends with .exe.
    • The -o flag specifies the output file.
  6. 6

    Blazon the name of your new plan and printing Enter . For case, if you created a program called hello.exe, you tin can type hi or howdy.exe. This runs your C program from the command prompt.

  7. Advertisement

Ask a Question

200 characters left

Include your e-mail accost to get a message when this question is answered.

Submit

Advertizement

About This Commodity

Article Summary Ten

1. Install MinGW.
2. Add the compiler path to your system environment variables.
3. Open an elevated command prompt window.
4. Enter the directory of the C code.
5. Type gcc filename.c -o filename.exe and press Enter to compile.
half-dozen. Run the program by typing its name and pressing Enter.

Did this summary help y'all?

Thanks to all authors for creating a folio that has been read 7,010 times.

Is this article up to date?

Source: https://www.wikihow.com/Run-C-Program-in-Command-Prompt

Posted by: millernuals1966.blogspot.com

0 Response to "How To Compile And Run C Program In Windows 7"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel