On Fri, 19 Apr 2013, Chris Cannam wrote:

> Note that there is no semantic difference between ++i and i++ in this
> context either -- not in C++ and not in C. Both of them have the same
> effect, which is to increment i, even though they return different
> results -- and in the context of a for loop as above, the result is
> not used for anything so the difference is irrelevant.
> 
> That is, the ++i in
> 
> for (i = 0; i < 10; ++i)
> 
> says "increment i, return the incremented value, and do nothing with
> it because it's not assigned to anything". The net result is simply to
> increment i. While the i++ in
> 
> for (i = 0; i < 10; i++)
> 
> says "increment i, return the value before it was incremented, and do
> nothing with it because it's not assigned to anything". The net result
> is again simply to increment i.

I was sure that it makes a difference inside:

#include <stdio.h>

main()
{
int i;

printf("loop 1 should start with 0\n");
for (i=0;i<10;i++) { printf("%d\n",i); }

printf("loop 2 should start with 1\n");
for (i=0;i<10;++i) { printf("%d\n",i); }
}

But it doesn't. Sorry for the brainfarts of an old man.

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to