Learning C by Example/Windows

From Wikibooks, open books for an open world
< Learning C by Example
Jump to: navigation, search

For getting started with C under Windows my suggestion is to install the MinGW as follows.

Download MinGW from http://www.mingw.org/ (currently the download is hosted at SourceForge at http://sourceforge.net/projects/mingw/files/)

When you are requested to select components please select at least the C Compiler and the MSYS Basic System.

A process will start which downloads and installs the required components.

After successful installation a link to MinGW Shell should now exist under Start -> Programs -> MinGW.

To test your installation use a text editor like Notepadd++ (http://notepad-plus-plus.org/), type the following C program

#include <stdio.h>
int main() {
  printf("Hello, world!");

  return 0;

and save it as test1.c under the directory C:\MinGW\msys\1.0\home\username\ (Note: please replace username with your windows username and I also assume you installed MinGW under C:\MinGW, if otherwise please change it to where you installed MinGW).

Find and click the MinGW Shell under Start -> Programs -> MinGW.

A shell window like the one below should now be visible.