Dr. Janzen's C Code Style Guidelines

Students should use the following Code Style Guidelines for all programs they write in this class. This style is based on the K&R code style with no tabs.
  1. Function and Variable Names
  2. Indenting For example, the following is correct:
    int main(void)
    {
        int numTacos;
        if (numTacos > 0) {
             doSomething();
             doSomethingElse();
        } else {
             doSomethingElseElse();
        }
        return 0;
    }
    
  3. Spacing
  4. Comments

Automatically Applying Code Style

Before you turn in a program, you should use the following command on vogon:

indent -kr -nut your_program.c

You can read about the indent program online or by typing man indent on vogon.

The indent command will make a copy of your_program.c to your_program.c~ before making changes to your_program.c.