use of ++i, i++

From: Greenhorn (teachgreenhorn_at_yahoo.com)
Date: 02/26/05


Date: 26 Feb 2005 11:28:18 -0800

hi,
  From reading some guides i understood that prefix, postfix operate
this way, former executes the increment right away, latter executes the
increment after the immediately after the immediately following end of
statement. Is that correct ?

If i go by that rule, the below two statements are equivalent

for(i=0;i < 1;i++)
 printf("The first value printed for i is %d", i);

for(i=0;i < 1;++i)
 printf("The first value printed for i is %d", i);

The outputs are same here as printf(...) statement above is the
immediately following end of the first statement after the 'increment
operator(s)'

 Thanks in advance.
   
           greenhorn.



Relevant Pages

  • Re: use of ++i, i++
    ... >> From reading some guides i understood that prefix, postfix operate ... >> this way, former executes the increment right away, latter executes the ...
    (comp.lang.c)
  • Re: use of ++i, i++
    ... > From reading some guides i understood that prefix, postfix operate ... > this way, former executes the increment right away, latter executes the ...
    (comp.lang.c)
  • Re: use of ++i, i++
    ... > this way, former executes the increment right away, latter executes the ... The "immediate" value passed for i is what your talking about. ...
    (comp.lang.c)
  • Re: use of ++i, i++
    ... > this way, former executes the increment right away, latter executes the ... The actual difference is that the prefix increment operator ... yields the original value. ...
    (comp.lang.c)
  • Re: why not use i++ instead of ++i in for()?
    ... > postfix forms of increment and decrement operators" goes into great detail ... > about pre and postfix operators and what the differences are. ... > The reason for this is that with a pre-increment operator, ... This all depends on the implementation, and the lengths of the strings ...
    (microsoft.public.vc.stl)