c++ - Break for loop with function? -
void fbreak(int i){ if(5==i) break; } void main(){ for(int = 0;i<10;i++){ fbreak(i); } }
i want function fbreak break loop. seems code not work.
in fact trying implement stadard algorithm std::find
(or std::find_if
) declared in header <algorithm>
you write program following way
bool fbreak( int ) { return == 6; } int main() { int = 0; while ( < 10 && !fbreak( ) ) i++; }
take account function main shall have return type int
.
Comments
Post a Comment