Friday, May 21, 2010

In the programming language C++, what does the function exit() do, and how do you use it?

I understand that it is a command to exit the program, but what I *don't* understand is why I see a number inside the () as a parameter. In some examples, I see people calling the function and it looks like this: "exit(8);". What is the 8 doing inside the parentheses...?

In the programming language C++, what does the function exit() do, and how do you use it?
It is a return code from the program. The shell that ran the program can check to see if the program exited with an error or normally. I believe return 0 is for normal exit, and return anyother number is for an error.


No comments:

Post a Comment