So, you've decided to learn C? Well, you made a good choice. This first tutorial is just how to compile a program, and kind of just learn how C works.

Depending on the compiler you want to use, the instructions vary. But, basically you will do the following steps.


For Command-Line compilers on Windows
  1. Open up Notepad or an equivalent text editor, NOT a word processor or something with fonts.
  2. Type in the following:
    #include <stdio.h>
    
    int main(void) {
        printf("Hello, World!\n");
        return 0;
    }
    
  3. This is the traditional Hello, World program. Save it as something like "hello.c" ( with the quotes in Notepad).
  4. Open a command prompt (or a DOS command line)
  5. Change to the directory that you saved hello.c in (using cd )
  6. Execute gcc -s hello.c -o hello.exe (For other compilers, look at your manual)
  7. If you get an error, check your typing and try again.
  8. Otherwise, type hello and press enter.
  9. You should get a Hello, World! message. Try going back and changing the message.
When you're done experimenting, let's look at what this means: Double quotes (") mark strings. So, "Hello" is a string, whereas 'Hello' is not. (Look-ahead fact: ' marks a char constant). "\n" prints a new line to the "console" (screen).

Got that? Good. Now, try to make a program that . . .

Your solution should look something like this:
#include <stdio.h>

int main(void) {
    printf("Hello from C!\n\n\n\n");
    return 0;
}
It's okay like this, as well:
#include <stdio.h>

int main(void) {
    printf("Hello from C!");
    printf("\n\n\n\n");
    return 0;
}
They do the same thing.

C ignores whitespace (Tabs, spaces, enters). So,

    #include    <stdio.h     >
   
   
   
   int             main( void    )               {
          printf(        "Hello, World!\n"        )              ;
            return    0   ;
                     } 
Will do the same as the first Hello, World! program.