Apologies for the noob question here, but it's been a very long time since did any C.
can I just return a value from within a for loop to end loop execution or do I need to break and then return a value? Is this ok:
or must i do this?Code:int i; for(i = 0; i < upper_limit; i++){ if (my_array[i] == val) { return i; } }
Code:int i; for(i = 0; i < upper_limit; i++){ if (my_array[i] == val) { break; } } if (i == upper_limit){ return -1; } else { return i; }



LinkBack URL
About LinkBacks


