Actions

EmSys

CCoding Style - Be careful with side effects3

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)

Be careful with side effects ...

It is not just increment and decrement that have side effects; Input/Output is another source of behind-the-scenes action.

scanf(“%d %d”, &yr, &profit[yr]);

Break it into two statements:

scanf(“%d”, &yr);
scanf(“%d”, &profit[yr]);