When array[j][i] == objects[0] I want to break from the whole for loop.Code:does this work:
for (j=height;j>0;j--)
{
for(i=0;i<width;i++)
{
if(array2[j][i] == objects[0])
{
bottomRow = j;
break;
}
}
}
Printable View
When array[j][i] == objects[0] I want to break from the whole for loop.Code:does this work:
for (j=height;j>0;j--)
{
for(i=0;i<width;i++)
{
if(array2[j][i] == objects[0])
{
bottomRow = j;
break;
}
}
}
Something like that, since I assume you don't want a goto.Code:for this and that
for this and that
if something
flag is set
break
if flag is set
break
Quzah.
I have tried this:
But once i uncomment the commented out bit it does NOT work properly. why?Code:int topRow, bottomRow, leftCol, rightCol, flag=0, flag2=0;
for (j=0;j<height;j++)
{
for(i=0;i<width;i++)
{
if(array2[j][i] == objects[0])
{
topRow = j;
flag = 1;
break;
}
}
if(flag==1)
break;
}
/*for (j=height-1;j>=0;j--)
{
for(i=0;i<width;i++)
{
if(array2[j][i] == objects[0])
{
bottomRow = j;
flag2=1;
break;
}
}
if(flag2==1)
break;
}*/
for(i=0;i<width;i++)
{
array2[topRow][i] = 80;
}
Ok working for some reason now