Node:Declarations and initialization, Next:, Previous:Variable and function names, Up:Style

Declarations and initialization

You should explicitly declare the types of all objects. For example, explicitly declare all arguments to functions, and declare all function that return integers to return type int, even though the ANSI Standard permits omitting the int.

If there are only a few declarations, then initializing variables where you declare them can be tidy, but if there are many variables to declare, then it is usually better to declare and initialize separately, for the sake of clarity. In a long function, it is often good to initialize the variable near where you are using it, so that someone reading the code does not have to hunt around in the function to discover its initial value. (See Initialization.)