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 - Variable and function names

Node:Variable and function names, Next:, Previous:Comments and style, Up:Style



Variable and function names

The names of variables and functions in a program serve as comments of a sort, so try to give your variables descriptive names (for example, num_of_books, cost_per_entry, or distance_from_center). Names should be in English, like other comments.

Use underscores rather than internal capitalization in names, so that Emacs word commands can be useful within them -- thus distance_from_center rather than distanceFromCenter or DistanceFromCenter. In fact, upper-case letters should be reserved for macros and enum constants. Macros should be completely in upper case, for example STANDARD_SIZE.

It used to be common practice to use the same local variables (with names like temp) over and over for different purposes within one function. Instead, it is better to declare a separate local variable for each distinct purpose, and give it a meaningful name. This not only makes programs easier to understand, it also facilitates optimization by good compilers.

 
 
  Published under free license. Design by Interspire