[ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The if
keyword should be followed by one space, then the opening paren and conditional expression. We also use Stroustrup-style else
blocks, rather than the K&R ’cuddled’ else
:
if (x) { ... } else { ... } while (1) { ... } for (i = 1; i < 10; i++) { ... } do { ... } while (x);
Single-statement if blocks should be isolated to a single line:
if (x) stmt();
not:
if (x) stmt ();
Notice that there is a space between if
and (x)
, and also between stmt
and ()
. This should be followed throughout the code.
If an if
block has an else if
or else
, all parts of the construct must be bracketed, even if one or more of them contain only one statement:
if (x) { foo(); } else if (y) { bar(); } else { bas(); }
This document was generated on September 20, 2023 using texi2html 5.0.