Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why can't I use EXIT_SUCCESS instead of 0 in the return statement in Visual Studio Code?

Why can’t I use EXIT_SUCCESS instead of 0 in the return statement in Visual Studio Code? I get the error:

id "EXIT_SUCCESS" is not defined

#include <stdio.h>

int main(void)
{
    puts("Thanks for help");
    return EXIT_SUCCESS; /*problem*/
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The definitions of the EXIT_SUCCESS and EXIT_FAILURE macros are in the "stdlib.h" header file, so you need to #include <stdlib.h> in order to use them.

(Some compilers may implicitly include that header when you include "stdio.h" but you can’t rely on that behaviour.)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading