CS2141 Style Guidelines

White Space

The use of white space is very important in making your code readable. You must be consistent in the use of white space. 

Expressions must have one white space between each operator and operand.  

Exceptions: 

AVariable = x + y;

for (int i = 0; i <= a + b; ++i)

//notice the spaces before the {, but not with [] or ()
if ((x < y) && (x > z)) {
...
} else if (array[i] != 0) {

}

// There should not be spaces around the -> operator
int c = cow->getAge( );

// The ?: operator is a special exception
minvalue = (myval > yourval) ? yourval : myval;

//Notice that the * operator does not need a space when dereferencing, but it does when multiplying
//How hard would this be to read if there were no spaces.
int x;
int* mynum = &x;
x = (mynum*)++ * --x;


//using whitespace / indention to break up a long line
if (((board[x][0] == board[0][x]) || board[x][1] == board[1][x]))
  && ((board[y][0] == board[0][y]) || board[y][1] == board[1][y]))
 && (board[x][y] == board[y][x])) {
...
}