C Tutorial

Introduction

C is an extremely powerful programming language. C is a language written by programmers for programmers, it became the most popular programming language ever in 1978. UNIX, its tools, and C were developed almost simultaneously; C grew up with UNIX but has since then left its home and is available on just about every computer system around. The development of C is not over, a researcher Bjarne Stroustrup Of Bell Laboratories began experimenting with an object orientated flavour of C that he called C++ (c plus plus). C++ extended C, in Bjarne's words "making a better C". This tutorial focuses on C, not C++. The X3J11 committee have adopted some of Bjarne's proposals into the ANSI C standard and since then an ANSI C++ standard has been created.

C++, however, didn't take over from C. C++ isn't for everyone and when learning C it's advised that you stick to the basics, learn to program in C, and when you're ready, move onto object-orientated C++.

C is a compiled language. For those of you that know Perl or PHP, you know that you write the source code and the Perl or PHP interpreter compiles the script on the fly (or interprets it). With C you must compile your source code into "machine language" before you can run the program. You write the source code, compile that source code into machine language that the computer can understand, and then run your program. Here is what you need to do:

Install a Compiler, there are many out there.

Learn the Basics of C.

Compile your source code into machine code and run the program.

Let's go on and learn more about compilers.

Compilers

When you have written your C program in source code, you must then compile it into machine code.

"A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses. Typically, a programmer writes language statements in a language such as Pascal or C one line at a time using an editor. The file that is created contains what are called the source statements. The programmer then runs the appropriate language compiler, specifying the name of the file that contains the source statements."

So basically, a compiler converts source code into executable code that can be processed by your computer. Source code enables the programmer to write a program at a higher level and logically spell out what they want the program to do. The compiler then converts these logical steps into a language the processor can understand.

Which Compiler?

There are many compilers to choose from, and it depends what operating system you're using, but here are a couple links to compilers that are quite popular.

Borland's Site - Borland are currently giving away Borland C++ 5 for free.

DJGPP - DJGPP is a free compiler that has its own graphics library. It's a pretty big download and can be tricky to set up, but it's worth it.

BloodShed - Another free compiler, a 6MB download, very easy to set up and it runs in windows.

Remember, C++ compilers can also compile pure C source code, so you may as well get a C++ compiler, as if you ever move onto C++ you wont have to download a separate compiler.

Ok that clears compilers up, let's take a look at a simple C program. It'll have to be simple as I'm very new to C, so I can only cover the very basics.