Placement of variable declarations in C
Placement of variable declarations in C
Posted Oct 27, 2007 15:58 UTC (Sat) by tjc (guest, #137)In reply to: Placement of variable declarations in C by RobSeace
Parent article: A potential competitor for GCC: pcc
Just declare one "int i;" at the top of the function, and use it in ALL for() loops! ;-)If you're not too set in your ways you might want to try "int ii;" instead. I've been doing this for a few years, and while it looks odd at first, I got used to it. It's a lot easier to find "ii" in code; searching for "i" is futile.
Posted Nov 18, 2008 18:40 UTC (Tue)
by pjm (guest, #2080)
[Link]
Many IDEs go one step farther and allow searching for just the current variable as distinct from other variables & functions of the same name.
Incidentally, I hope that the original poster is joking (as the ;-) suggests) in the suggestion to use a shared variable for all temporaries. Such sharing makes it harder to modify one use of the variable because one needs to check whether subsequent code is using the resulting value.
(off-topic) Searching for variables
