Introduction to C
Uploaded by CollegeKid2002 on Oct 25, 2001
This is an introductory essay on C programming. It assumes that you know varying amounts about computers and programming in general. First, I recommend that you purchase The C Programming Language, Second Edition by Brian W. Kernighan and Dennis M. Ritchie (referred to by everyone as K&R2), and also Expert C Programming: Deep C Secrets by Peter van der Linden, and keep both at your side while you program. They are very useful and very handy books. The C language has changed some since the publication of these books, but overall its flavor is still much the same as it has always been.
This essay will focus entirely on "modern C", that is to say, the ANSI Standard C language dating from 1989. A revised standard was created in 1999, incorporating numerous and sometimes signficant changes to the language; however, I will not refer to it (much) here since its features are not so much of interest to beginning programmers, and (as I write this, 2001) "C99" compilers are not in wide, or any use at all. Beware: Peter van der Linden and K&R2 occasionally refer to anachronisms which you do not need to know about, and in fact probably should not know about, as they are confusing, useless, and dated.
First, C is a compiled language, like C++ or Fortran (speaking of dated, useless anachronisms) and unlike interpreted languages such as BASIC and DrScheme. Additionally, C has steps that Java (which occupies a middle ground between compilation and interpretation) lacks.
Conceptually, a programmer creates a series of text files, named in the manner *.c and *.h, which make up the source code to a program, and then uses a C compiler on them. The compiler shall behave as if first it "preprocesses" the text files, and then "compiles" them. You do not need to know the magic that actually goes on behind the scenes; in fact, you should stay away from knowing too much about your compiler. Compilers vary on different systems. If you program in a Windows environment, I suggest DJGPP, which is a port of the freedom software compiler gcc for the Linux platform.
Preprocessing only acts on the text files themselves. The preproccesor, and the commands used to instruct it, form a sort of primitive proto-language on top of C. In fact, this is how it historically evolved, if you are curious. The C preprocessor is highly useful, and isn't...