Click here to Skip to main content
15,891,993 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...
Posted
Updated 24-Nov-11 5:58am
v3

Add header file <stdlib.h>
like,
C++
#include <stdlib.h>


For Example,
C++
#include <stdlib.h>

int main( void )
{
   exit( 0 );
}



Regards
 
Share this answer
 
v4
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 http://stackoverflow.com/questions/461449/return-statement-vs-exit-in-main[^]

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)



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