Per Inge Mathisen schreef:
> On 1/28/07, Dennis Schridde <[EMAIL PROTECTED]> wrote:
>> C-Question (no criticism, I just don't know my C)
>> for(i=0; i<1; i++) is equivalent to for(i=0; i<1; ++i) as long as the 
>> increment is the sole thing done (eg. it doesn't read like for(i=0; i<1; 
>> i++, 
>> sum+=i))?
>> What I initally thought was that for(i=0; i<1; i++) translates to i=0; 
>> while(i<1) {...; i=i+1;} while for(i=0; i<1; ++i) translates to i=0; 
>> while(i<1){i=i+1; ...}. I guess I was wrong with that idea?
>>     
> Yes. It is only different if you do several things in the same
> expression, such as array[i++] = 1.
Yes, I believe the compiler optimizes a single `i++;' statement to `++i;'.

As for the while-loop, I'm not sure what your trying to say/ask there.
Anyway what does matter is that if you put the `while (boolean check)'
at the beginning or ending of the loop. If you check at the end of the
loop then your loop will always execute at least once.

-- 
Giel

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev

Reply via email to