- Aug 1, 2000
- 1,420
- 1
- 0
hey all, hope I can get the usual quick answer here 
I need to break a for statement using an if statement, and I'm wondering if this will work...I'd compile it now, but the code's not yet close enough to completion to go through the hassle.
for (j = 0; j < 15; j++)
{
if (locations[J] == RINGOS_HAND)
{
printf ("You already have something in your hand.\n"
;
break;
}
else if...
(my else if leads me to the same question-so heres the code for the else-if)
else if (locations[j] == locations[15])
{
locations[j] = RINGOS_HAND;
same thing here-i'd need to break both the else if and the for statements...
}
else...
basically, I want to check each value in the array, and break the ENTIRE FOR STATEMENT if it does-but I'm doubting whethere the break I have will do it (i think it might only break the if), a break after it would (i think) be meaningless, and a break before the else if would definitely end the for statement, which, at that point, I would NOT want to do...any ideas?
one note: values in the array can repeat-so, for example, locations[0] can = locations [10] = Name of place...thats why i need to break the for statement
Thanks
I need to break a for statement using an if statement, and I'm wondering if this will work...I'd compile it now, but the code's not yet close enough to completion to go through the hassle.
for (j = 0; j < 15; j++)
{
if (locations[J] == RINGOS_HAND)
{
printf ("You already have something in your hand.\n"
break;
}
else if...
(my else if leads me to the same question-so heres the code for the else-if)
else if (locations[j] == locations[15])
{
locations[j] = RINGOS_HAND;
same thing here-i'd need to break both the else if and the for statements...
}
else...
basically, I want to check each value in the array, and break the ENTIRE FOR STATEMENT if it does-but I'm doubting whethere the break I have will do it (i think it might only break the if), a break after it would (i think) be meaningless, and a break before the else if would definitely end the for statement, which, at that point, I would NOT want to do...any ideas?
one note: values in the array can repeat-so, for example, locations[0] can = locations [10] = Name of place...thats why i need to break the for statement
Thanks