how do you exit from inside a function?
The easy way is to "return". Be carefull here as the return value is dependant on your function declaration.
Is that what you wanted?Code:int foobar(int& x){ while(x < 500){ x++; } return x; //go back to main } int main(void){ int x = 0; foobar(x); cout << x << endl; return 0; //return 0 to Operating System }
Oh... you can use exit(0) too, to finish the program at any time.....
Last edited by Fordy; 11-22-2001 at 02:31 PM.