I want to remove goto statements in my C code. The following shows the my C code snap
void placeFruit(void)
{
resetfruitX:fruitX=rand()%20;
if(fruitX==0||fruitX==width)
goto resetfruitX;
resetfruitY:fruitY=rand()%20;
if(fruitY==0||fruitY==height)
goto resetfruitY;
}
anyone can help me
>Solution :
void placeFruit(void){
do fruitX=rand()%20; while(fruitX==0||fruitX==width);
do fruitY=rand()%20; while(fruitY==0||fruitY==width);
}