C Beginner - The Hello World program does nothing on Windows from the command prompt


I'm about to start learning C (I need to program something in C, to convert it into MIPS later).

I'm on Windows 8, and downloaded MinGW and set the path variable to its directory, so that the gcc or g++ commands should work in command prompt.

I copied the following Hello World example into a .c text file.


int main(void)
{ // This is a comment
  printf("Hello world!\n");
  return 0;

However, although I'm in the correct directory as the file, on command prompt when I type "gcc helloWorld.c" it pauses for a couple of seconds, and then doesn't do anything. It just acts as if the program has finished and allows me to type something else in.

This is likely to be a simple mistake - I don't really understand what I'm doing. But can anyone help me out?

When you issue the gcc command you are actually COMPILING the source code, NOT RUNNING the program. The Compiling process creates an executable file to that you can run.

In the example by previuous poster:

gcc -o helloWorld helloWorld.c

The -o parameter is the [o]utput name of the executable file to be created, let say "helloworld.exe" (as you are using Windows). This should create a new file helloworld.exe, Now you can RUN that file.

Should read a little bit more on general C programming and compiling.