Conventions

Introduction

This short section of the C programming tutorial will describe common organizational methods in the C programming language.

Preprocessor Directives (such as #include)

These are almost always declared at the top of a web page and are rarely given indentations.

Code Inside of Curly Brackets

Code inside of curly brackets should be a tab more to the right than the code outside of the curly brackets. Visual Studio and Netbeans do this for you automatically when you press enter whenever the cursor is after a curly bracket.

Functions

Functions should always be at the same level of indentation from each other (usually, no identation).

Function Parameters

In the following line of code from the last two sections' example (printf("%i", 8);), each group of text inside the parentheses (each parameter is seperated from the other by commas) is a parameter. It is common practice to add a space after each comma before each additional parameter. It is also common practice for the parentheses not to be seperated from the parameters by spaces(for example, aFunction(a,b), not aFunction( a,b )).

Naming

By convention, in C, the first word of every name is completely lowercase, and the first letter of each following word is uppercase. So the following would be a good way to name a variable: anInterestingVariable. This is done so that the variable is easy to read, despite the fact that adding spaces to variable names is not allowed. This applies to both variables and functions. There are a few exceptions where all of the letters in a variable are capitalized, with each individual word being seperated by an underscore(_), but those exceptions will be covered later.

Now it's time to actually start writing code (again)!