Thread: for loop code
View Single Post
  #5 (permalink)  
Old 07-09-2008, 06:21 PM
Aereshaa's Avatar   
Aereshaa Aereshaa is offline
Guru
 
Join Date: Apr 2008
Posts: 498
Rep Power: 9
Aereshaa is a jewel in the roughAereshaa is a jewel in the roughAereshaa is a jewel in the roughAereshaa is a jewel in the rough
Default Re: for loop code

I think he means:
'In the expression for(A,B,C){D;}, what are the legal values of A, B, C, and D?'
The answer is that they can be any legal C statements. For example, for a countdown:
Code:
int i = 11;
for(printf("Countdown to liftoff:\n"); (i = i - 1) != 0; printf("%d\n", i))sleep(1);
for(A,B,C){D;} is functionally equivalent to
Code:
A;
start_of_loop:
if (!B) goto end_of_loop;
D;
C;
goto start_of_loop;
end_of_loop:
So you can put whatever you want!
Reply With Quote

Sponsored Links