How to use exit in C

This is a discussion on How to use exit in C within the C Programming forums, part of the General Programming Boards category; Hi...
I'm doing a simple program in C, and i need a option that terminates the program.
For example, instead ...

How to use exit in C

Hi...

I'm doing a simple program in C, and i need a option that terminates the program.
For example, instead of appearing "Press any key to continue..." the program will instantly close.
I've been googling and i found some references on a exit command, but i don't have any ideia on how to use it :-S

The integer that exit() takes as an argument is the return value that you want to send to the calling application. Its usage outside of main() should generally be restricted to fatal errors that your program has no way of gracefully handling. I believe all normally working applications should exit by allowing the flow of the program to finish in main() if possible.

I'm doing a simple program in C, and i need a option that terminates the program.
For example, instead of appearing "Press any key to continue..." the program will instantly close.

I take it that you're running the program from MSVC and you want it to exit immediately? In that case, you'll have to run the program from the command prompt or something. I think MSVC will print "Press any key to continue" no matter what.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell