CCoding Style - Parenthesize to resolve ambiguity

From EdWiki

Revision as of 09:30, 23 June 2015 by Jshankar (Talk | contribs) (1 revision imported: EdWiki -- Emsys pages from Shukra)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Parenthesize to resolve ambiguity

  • C provides a very pernicious precedence problems, and it is easy to make a mistake.
  • When mixing unrelated operations, it’s a good idea to parenthesize.
  • Parenthesizes specify grouping and can be used to make the intent clear even when they are not required.
  • Because the logical operators bind tighter than assignment, parenthesis are mandatory for most expressions that combine them, e.g,
while( (c = getchar() ) != EOF)