C Style Guide

This document sets out the style which is to be followed in all submitted work in this course.
  1. C Program Structure
  2. Names
  3. Layout
  4. if, while
  5. Declarations
  6. Functions
  7. Structs
  8. Comments
  9. Compiler Options
  10. Thanks

C Program Structure

  1. header comment
  2. #included files
  3. #defines
  4. local struct typedefs
  5. local prototypes
  6. global variables (only if absolutely necessary)
  7. main function (if present)
  8. local functions
  1. header comment
  2. #included files
  3. #defines
  4. struct typedefs
  5. prototypes
  6. (extern) global variables (only if absolutely necessary)

A header comment should include:

// Name, Student Number.
// Date.

// What this file is for (one line summary).

// Possible longer explanation, copyrights, etc.

Names

Layout

if, while

Declarations

Functions

Structs

Comments

Compiler Options

Thanks

This document is based on the programming style guide for first year courses at CSE@UNSW.