Of course you can. The for loop is just shorthand for:
Code:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
{
int i = 20; // Initialize
/* The loop */
forloop1:
printf("%d\n", i);
/* The loop */
if(!(i > 0)) goto forloop1end; // Check condition
--i; // Iterate
goto forloop1; // Loop
forloop1end:
}
return EXIT_SUCCESS;
}
So inserting a return doesn't harm anything:
Code:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
{
int i = 20; // Initialize
/* The loop */
forloop1:
printf("%d\n", i);
if(i == 5) return i;
/* The loop */
if(!(i > 0)) goto forloop1end; // Check condition
--i; // Iterate
goto forloop1; // Loop
forloop1end:
}
return EXIT_SUCCESS;
}