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 - Hidden operators and style

Node:Hidden operators and style, Next:, Previous:Global variables and style, Up:Style



Hidden operators and style

Hiding operators away inside other statements can certainly make programs look elegant and compact, but it can make programs harder to understand. Never forget that besides being a set of instructions to the computer, programming is a form of communication to other programmers. Be kind to the reader of your program. It could be you in months or years to come.

Statements such as:

if ((my_int = (int)my_char++) <= --my_int2)
  {
    ...
  }

are not good style, and are no more efficient than the more longwinded:

my_int = (int) my_char;
my_char++;
my_int2--;

if (my_int <= my_int2)
  {
    ...
  }

 
 
  Published under free license. Design by Interspire