Programming in C

C is a general-purpose procedural programming language, developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories in order to re-write the Unix operating system originally developed in assembly language by Ritchie and a colleague, Ken Thompson. The language was called "C" because it was in part derived from an earlier language called "B". As its origins suggest, it was originally intended for use as a portable systems implementation language, although it has been widely used for developing application software, and is still one of the most popular programming languages worldwide. The relatively low-level nature of the language allows the creation of efficient programs that will run on hardware with limited memory, such as embedded systems.

In 1978, Ritchie and Brian Kernighan (a colleague at Bell Labs who had been an important contributor to the Unix development effort) completed the first edition of a book called "The C Programming Language". The book, published by Prentice-Hall, was regarded by C programmers as the unofficial specification of the language (known as K&R C) for many years. The popularity of the language meant that it was adopted for the development of software for a wide range of applications and platforms. Many extensions to the language were developed as a consequence, and were subsequently made available as C programming libraries. A library is essentially a set of related functions defined in a separate file. The use of libraries was chosen as the primary means of extending the C programming language.

Due to the large (and growing) number of extensions, and a failure to reach a consensus on a standard library, the American National Standards Institute (ANSI) in 1983 formed a committee to establish a standard specification for C. The standard was duly published in 1989 as ANSI X3.159-1989 "Programming Language C", usually referred to simply as ANSI C. The standard was later adopted in a slightly modified form by the International Standard Organisation (ISO) as ISO/IEC 9899:1990. The ANSI standard incorporated many of the extensions that had been added to the original K&R specification. The second edition of "The C Programming Language", again written by Kernighan and Ritchie and published by Prentice-Hall, covers the ANSI standard version of the language. The C standard was revised again in the late 1990s resulting in the publication of ISO/IEC 9899:1999 in 1999.

Many of the sample programs provided in the following sections have been compiled and run as console applications using Borland Turbo C++ 2006, which at the time of writing is no longer freely available for download. They should work with other C/C++ compilers, however (I have tried some of these with Microsoft's Visual Studio 2008 without any problems). If you are looking for a good open source C/C++ compiler, I can recommend Code::Blocks, which provides an excellent cross-platform IDE.