Remove the code from main()
and put it in a function:
static void my_function(void)
{
/* lots of stuff here */
}
Then just call it:
int main(void)
{
my_function();
if(condition)
my_function();
return 0;
}
This is way cleaner than using a loop, in my opinion, since the use case was not really "loop-like". If you want to do something once or twice, break it out into a function then call the function once or twice. As a bonus, it also gives you a great opportunity to introduce a name (the function name) for the thing that your program is doing, which helps make the code easier to understand.