Sample programs
- STUDY THESE PROGRAMS. Reading and understanding what's going on in these samples is part of your homework, and I will assume that you have done that work as the term progresses.
- Ask questions. You won't understand everything in these samples on first reading, so collect your questions and get them answered.
- Experiment. You won't understand everything in these samples on first reading, so play around with them. Some of your best learning will start with "I wonder what happens if I make this change...".
- Building these programs.
For most of our programs, you should use the following compilation approach. We'll
discuss all the parts of this command over the first few days of the term.
gcc -Wall -Werror -g -o hello hello.c
- Pedagogical comments vs. production comments. These programs have tons of explanatory comments, because they are intended as pedagogical programs, not production programs. Production code (i.e., code intended for use by end users or submission as homework) should follow the commenting advice in our style guide. You're welcome to borrow code from these samples, but delete my comments before you're done working.