Click here to Skip to main content
15,615,280 members
Please Sign up or sign in to vote.
1.15/5 (3 votes)
See more:
I made an application in C++ (console app), but when i try to build it gives an error:
"exit" is not a member of global namespace ,
Can anyone tell me How to fix this ?
Thanx in advance...
Updated 24-Nov-11 5:58am

Add header file <stdlib.h>
#include <stdlib.h>

For Example,
#include <stdlib.h>

int main( void )
   exit( 0 );

Share this answer
On a sidenote, you shouldn't use exit unless your program ran into an error condition and you can not be sure all your objects are still in a well-defined state. The preferred way of returning from a program, is to call return in main(). See[^]

Not saying you are using it wrong, but the example in Solution 2 is of that type - that code should use return rather than exit.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900