tags:

views:

280

answers:

3

When reading/writing a file in my application, I want to exit(1) if the file is not closed correctly. On Windows it works well, but on Linux this error appears:

‘exit’ was not declared in this scope

How can I solve that?

Thanks.

+11  A: 

If this is in C, did you #include <stdlib.h>?

Kimvais
+5  A: 

If this is C++ you have to include cstdlib:

#include <cstdlib>
jrbjazz
A: 

I added cstdlib.h and it didn't work, But by stdlib.h it worked. Thanks very much

aryan
Please add any "afterthought" as a comment, not as an answer
Aviral Dasgupta
it's <cstdlib> for C++, <stdlib.h> for C
Eli Bendersky
This should be a comment, not an answer. Also, if Kimvais answer was the correct one, please mark the checkmark below the score for that answer.
Martinho Fernandes
My dear frindsI am sorry about that. excuse me.
aryan
There should be no `<cstdlib.h>`. The differences between `<cstdlib>` and `<stdlib.h>` are that the first is for C++ use only, not C, and puts all names into the `std` namespace, while the second puts them in the global namespace.
David Thornley