This is the home page for the advanced C track of CS 11. This information is for the spring 2004 term.
NOTE: This track is UNDER CONSTRUCTION! Hopefully one day it will be complete ;-)
If you are not sure what constitutes a reasonable amount of programming
experience, look at the assignments for the C
track. If any of them seem even remotely challenging to you, you should
not be in this track. I will assume that anyone taking this track has
mastered all of the material in the C track, except possibly for the material
on Makefiles. I will also expect that you know how to use a C debugger (such
as gdb). If you don't, you should read this page. Knowing how to use a debugger
will be an essential skill for this track.
You also need to have a reasonable familiarity with Unix to take this track.
All assignments will be run on Unix systems, and several will involve
Unix-specific system calls. You should be very comfortable with all basic
Unix commands, as well as text editing (I recommend emacs, which
is the best code editor, but this is not required), and use of a C compiler
(ideally gcc, which is the compiler we will be using). You do
not have to understand Unix system calls, as we will cover that material as
we get to it.
Note that compared to most of the other CS 11 tracks, this track requires much more "programming maturity". If you need or expect a lot of hand-holding, you should definitely not take this track. This track is for serious programmers who are comfortable with the following kinds of activities:
Finally, you must have an account on the CS cluster. If you do not have such an account, please get one at http://www.cs.caltech.edu/cgi-bin/sysadmin/account_request.cgi before submitting the first lab.
However, feel free to drop in to my office at any time. I'm unlikely to be in in the mornings, but I'm often around fairly late at night. If you need to meet with me outside of office hours, sending me email is a good idea.
Minilectures will typically last about an hour. Attendance is optional; if you can do the work without minilectures, it's fine with me. However, since this track covers some fairly complex material, I strongly suggest that you attend.
In special cases, I may grant extensions on homework to individuals in special circumstances. The duration of the extension will depend on how compelling the reason for the extension is.
All assignments must be completed in order to pass the course, regardless of the numerical grade you get. If you're heading for an F, I will encourage you to drop the course so as not to hurt your academic record. If you have more than two assignments that haven't been completed satisfactorily by the time I have to submit the grades, you will get an F. If you have only one or two incomplete assignments I may give you an E instead, but you will have to complete the assignments as soon as possible.
~/cs11. In
this directory, create another directory called advanced_c. Put
the files for each week's assignments in a separate subdirectory called lab1,
lab2, etc. I will collect the assignments on the day that they're due. If
your assignment is not ready, let me know by email and also let me know when
it's ready to be graded. I'll send you grades and comments by email.
/*** THIS IS ONE OF MY COMMENTS (ALL UPPER CASE, 3 ASTERISKS AT LEFT).
***/
Please don't write your own comments in this style (at least for the duration
of this course). For style (code formatting) issues I will sometimes
identify the problem via a tag that can be looked up in the C style guide. An example might
be:
/*** STYLE: [STMTS_ON_LINE] ***/
i = 1; j = 2; k = 3;
which says to look in the style guide for the style violation called
[STMTS_ON_LINE]. If you do that you'll see that I don't like to see
more than one statement on a line. Poor code formatting is so common that
this notation saves me a lot of work, as well as forces you to read the style
guide. In addition, there is also a C
style checking program which you will use to check the style of your
code. This will give you instant feedback in a way that I can't, but it
won't catch all style violations. Compared to most instructors, I am very
picky about code formatting, so please use the style checker; it'll save you
a lot of time. I will be especially severe for the most common style
mistakes described in the style guide, and will not hesitate to make you
rewrite code that violates these guidelines.
% gcc -Wall -Wstrict-prototypes ...This will help you avoid many obvious problems. All submitted code must compile without warnings, except in special cases (e.g. lexers and parser generators sometimes create code that generates compiler warnings that can't be easily removed).
Interestingly, I strongly suggest that you do not use the compiler
options -ansi -pedantic, which I require in the C track. The
reason for this is that on Linux systems, those compiler options interact
badly with header files for obscure reasons, often forcing you do manually
declare prototypes for functions which should be in the standard header
files. So don't use those options.
enum and union types
typedef
goto statement
#ifdef, #if defined(X),
and other preprocessor fun
setjmp(), longjmp()
make and Makefiles
valgrind
getopt for command-line argument processing
readline library for line editing (useful
in interactive interpreters, for instance)
flex and bison)
fork() and exec()
(writing a simple command shell)
getenv() and setenv()
lab1 lab2 lab3 lab4 assigned/due 4-7/4-21 4-14/4-28 4-28/5-12 5-5/5-19 Jimmy Jia (taion@its) Alan Somers (somers@its)
This book, known as "K&R", is a concise, complete, and readable description of the C language. If you do not have this book, I strongly recommend you get a copy.
This book, which I discovered by accident while browsing through the Caltech bookstore, gives very nice, readable descriptions of most of the material we'll cover in this track. I recommend you purchase a copy.
This book, despite having numerous 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.
This book, although very outdated, contains a lot of interesting information
about Unix and its philosophy, and has a nice introduction to using
lex, yacc and make to build an
interpreted language. Note that nowadays most programmers use
flex instead of lex and bison instead
of yacc, but the programs are almost identical.
This book is a classic tutorial and reference for Unix system calls. It's similar to the Molay book but more comprehensive and somewhat less friendly.
The interesting history of how C came to be, from one of its creators (Dennis Ritchie).