...

View Full Version : Need Help: C++ incriments in a for loop



Phoncible
08-29-2008, 04:32 AM
So I'm trying to use a for loop for something, but I need the increments to increase by two, not just one.

I.E. :
for (int i = 0; i < number; (i++)++) and also (i+1)++

It won't compile, always hanging up on this line; how do I do this?

Gox
08-29-2008, 04:54 AM
Perhaps:
for (int i = 0; i < number; i+2) {...} ?

EDIT: Oops, error above. Should read
for (int i = 0; i < number; i += 2) {...}

Phoncible
08-29-2008, 04:59 AM
Thanks, almost soon as I posted I realized it. I feel silly

ralph l mayo
08-29-2008, 07:27 PM
for (int i = 0, i < number; i = i + 2)

eak
08-29-2008, 08:12 PM
even shorter:

for (int i = 0, i < number; i+=2)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum