[lug] c question, int passed by reference

Sean Reifschneider jafo at tummy.com
Mon Oct 8 16:39:53 MDT 2007


On Mon, Oct 08, 2007 at 10:41:54AM -0600, Carl Wagner wrote:
>  *k++; 

Versus:

>  *l = *l +1;

If you don't have the precedence rules memorized, then you should always
explicitly parenthesize to ensure that it's obvious what the order you
expect to have happen is, when combining multiple operators.  In fact, I
always use parenthesis in this case so that it was obvious what I expected
to have happen.

It's kind of like the "always use braces" rule.  So, "(*k)++", or "*l =
(*l) + 1".  So, yeah, I rely on = precedence, but usually very little else.

Sean
-- 
 Any technology distinguishable from magic is insufficiently advanced.
                 -- Gregory Benford
Sean Reifschneider, Member of Technical Staff <jafo at tummy.com>
tummy.com, ltd. - Linux Consulting since 1995: Ask me about High Availability




More information about the LUG mailing list