c programming tips and tricks

Add white space before condensing your C code

C programmers love to bunch up statements, cramming as many of them as they can into a single line, such as


Admit it: Such a construction looks cool. It makes it seem like you really know how to code C. But it can also be a source of woe.

My advice: Split out the code before you condense it. Make liberal use of white space, especially when you first write the code. For example, the line

if( c != '\0' )

is easier to read than the line


After you write your code with white space — or use several statements to express something — you can condense, move out the spaces, or do whatever else you like.

In C language source code, white space is for the benefit of human eyes. I admire programmers who prefer to use white space over cramming their code onto one line, despite how interesting it looks.

Leave a Reply

Your email address will not be published. Required fields are marked *