Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Operators Up: Keywords, Operators and Declarations Previous: Keywords, Operators and Declarations   Contents

Keywords

You can't use the following reserved words for variable names, etc.
auto break case char const
continue default do double else
enum extern float for goto
if int long register return
short signed sizeof static struct
switch typedef union unsigned void
volatile while

A few of these haven't yet been described.

auto
:- This is the default Storage Class for variables so it's not explicitly used. static, which you've already met, is an alternative class.

const
:- If a variable isn't meant to change you can define it as const. E.g., If you create an integer using `const int i = 6;' then a later `i = 7;' will be illegal. However, if you create a pointer to i and use this to change the value, you'll probably get away with it. The main purpose of const is to help optimisers. volatile is the opposite of const.

enum
:- C has enumerated types, like pascal. E.g.
enum color {Red, Green, Blue};
They're not as useful as in pascal because C doesn't check if you set an enumerated type to a valid value.

register
:- You can suggest to the compiler that a variable should be kept in a register for faster access. E.g. `register int i' might help if i is a much-used indexing variable. An optimising compiler should use registers efficienty anyway. Note that you can't use the `&' operator on a register variable.


next up previous contents
Next: Operators Up: Keywords, Operators and Declarations Previous: Keywords, Operators and Declarations   Contents
Tim Love 2010-04-27