Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The GNU C Programming Tutorial - Declarations and initialization

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.)

 
 
  Published under free license. Design by Interspire