Learn C: Setting up the environment

This entry is part 1 of 7 in the series Learn C

Let’s start with the C language first.

The first thing is to get your computer set up so that you have a compiler to compile C.

This post will use the GNU C and if you prefer, you can set up the Visual Studio shown in a later post.

GNU (Geez, Not Unix) C compiler can be downloaded from http://mingw.com.  Visit the website and download the MinGW installation manager.

mingw

From the installation manager download gcc-core, gcc-g++, binutils, and the MinGW runtime. Next set the path of the windows to the bin directory of MinGW.

Now that you have the environment set up, you can write your first C program.

 

Learn C: What are the resources available on the web to learn C?

This entry is part 3 of 7 in the series Learn C

There is actually quite a lot of resources available online that you can tap into.

Here, there are these few links that I have found:

  1. Tutorials Point – with good introduction
  2. How Stuff Work – a bit surprised to find C stuff here
  3. C Programming
  4. Programming Simplified – quite a lot of examples that you can try
  5. C Tutorial – created more for students majoring in Physics
  6. C4Learn – this site has some very good and short examples that you can try out
  7. GNU C – a programming tutorial

If you have come across any good C introduction on the web, please share the link.

Learn C: A variation of the first program

This entry is part 4 of 7 in the series Learn C

#include <stdio.h>

void main()
{
    printf("\n");
    printf("Hello World");
    printf("\n");
    printf("This is my first program.\n");
}

hello1

The “\n” is a special character.  It means new line here.  Notice the 2 new lines in the hello program.

printf is a print function defined in stdio.h, that is also why there is an include statement in the beginning.

The “;” denotes the end of a statement.

Learn C: Special Characters

This entry is part 5 of 7 in the series Learn C

Special or control characters are invisible on the screen. They have special purposes usually to do with cursor movement and are written into an ordinary string or character by typing a backslash character \ followed by some other character.

In the hello example, the special character is “\n”.

These characters are listed below.

Special CharacterDescription
\bbackspace BS
\abeeping sound
\nnew line NL (like pressing return)
\rcarriage return CR (cursor to start of line)
\t
horizontal tab HT
\"double quotes (not all versions)
\'single quote character '
\\backslash character \