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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -