This is the home page for the C track of CS 11. This information is for the Spring 2008 term.
Go to this page for all the administrative information pertaining to this track.
C is a general-purpose programming language originally developed by Dennis Ritchie at AT&T Bell Labs in the 1970s. C was developed as a computer language that could be programmed at a reasonably high level but could also access machine-level entities like memory addresses, bits, bytes, etc. The objective was to create a portable language that could replace assembly language for all but the most performance-critical segments of code. This was done so that the (then new) Unix operating system would not have to be rewritten from scratch every time the microprocessor machine language on the latest and greatest new computer changed from what it had been on older computers. As a result of this heritage, C is often regarded as a language for operating systems programming, but it has been used for much more than that. By the way, the significance of the name "C" is that it was the successor to an even more primitive language called "B". As far as I know there was no language called "A" which preceded "B"; the predecessor of "B" was called "BCPL".
Compared to many other computer languages, C is a relatively low-level language. C programs can be compiled into very fast code. The price you pay for this is that you are responsible for every detail of your program; if you screw up, you will probably get a core dump (you'll find out what that is soon enough *chuckle*) or (on operating systems like Windows) your computer may just crash (perhaps with the infamous "blue screen of death"). It is very easy to corrupt memory, to leak memory, and to create incredibly obscure and hard-to-find bugs while programming in C. For instance, if you have declared an array of ten elements and then mistakenly write to the twelfth element, you will probably not find out about it until later on in your program when you try to allocate new memory, which will sometimes result in a core dump (and sometimes not). For this reason, C programs tend to be unreliable and full of bugs, although they are often significantly faster than programs written in other languages.
The most distinctive aspect of programming in C relative to other imperative languages is the way C handles pointers. A pointer can be thought of as a variable whose contents are a machine address where a value is stored. That value can itself be another address, so you can have pointers to pointers, etc. C uses pointers to implement arrays as well as to create a wide variety of data types. Pointers tend to cause a lot of confusion among new C programmers, so I will be dealing with them in detail.
Another distinctive aspect of C programming is the C preprocessor. This is a sort of language-within-a-language which is processed by simple string substitutions before the program is compiled.
In general, C is not a particularly difficult language to learn or to master. However, C programs tend to be quite difficult to debug because the language doesn't prevent you from shooting yourself in the foot. In addition, because C provides only the most rudimentary support for defining your own abstractions, C programs are often longer and less clear than those written in higher-level languages like Java, Python, Ocaml or Scheme. On the other hand, C provides a degree of control over the machine that most other languages cannot match. On the other other hand :-) very few programs require that much low-level control. Regardless, C is currently one of the most frequently used programming languages and all serious programmers need to master it.
Lecture 1
Lecture 2
Lecture 3
Lecture 4
Lecture 5
Lecture 6
Lecture 7
Lecture 8
Current grades for all students are located on this page.
Peter A. Darnell, Philip E. Margolis, C: A Software Engineering Approach, 2nd Ed.
This is a comprehensive introduction to the C language which is quite readable. It will be the main reference for the course.
Kernighan and Ritchie, The C Programming Language, 2nd Ed.
This book, known familiarly as "K&R", is a concise complete, and fairly readable description of the C language. This will be the reference textbook for the track. It's not easy reading for people with no programming experience, but the entire C language is described in it, so if you want to know about some fine point, this is the place to go.
Peter van der Linden, Expert C Programming: Deep C Secrets
This book, despite having lots of pretty glaring typos, is one of the few books that explains what is going on at the machine level during compilation and execution of a C program. It has much more information than beginners require, but more advanced programmers should read it.
The development of the C language
The interesting history of how C came to be, by Dennis Ritchie, one of the authors of K&R.