Originally Posted by
brewbuck
Not quite. Consider what happens when you do a continue statement inside the loop.
Code:
#include <stdio.h>
int main(int argc, char *argv[])
{
int i;
for(i=0;i<10;i++)
{
if(i == 5)
{
continue;
}
printf("i = %d\n",i);
}
printf("\n");
i=0;
while(i<10)
{
if(i == 5)
{
i++; /* Interesting line */
continue;
}
printf("i = %d\n",i);
i++;
}
return 0;
}
When I tried the above without the marked line, the program would hang. When I added the marked line, program execution continued normally, and the two loops behaved the same.
Commentary anyone?
Edit: Apologies for writing this in C, but the idea is exactly the same, and nothing should be changed.