stdlib Purpose

My teacher learned C++ when it first came out, so some functions and libraries he has shown us have been improved and/or deleted.

In most of the examples he has given us, he puts this in the declarations-

#include <stdlib.h>

So my question is, does this library still have any purpose? Or has it been replaced, and if so, by what library?
That looks like C, not C++. If I was going to use that (I wouldn't, but if I was) then I would use #include <cstdlib>.
<stdlib.h> (or <cstdlib> -- http://www.cplusplus.com/reference/clibrary/cstdlib/) contains important stuff. Of particular use are the standard macros EXIT_SUCCESS and EXIT_FAILURE, not to mention abort() and exit().

This is the simplest proper, portable C++ program:

1
2
3
4
5
6
#include <cstdlib>

int main(int argc, char* argv[])
{
    return EXIT_SUCCESS;
}
I tested out your code with <iostream> instead of <cstdlib>, and it worked perfectly. So did the abort() and exit() functions. I'm guessing that stdlib is no longer needed. Thanks though.
@youngcoder, If you're going to use EXIT_SUCCESS, you must include <cstdlib>. Your compiler probably includes it from within iostream, another compiler may not be so lenient.
Topic archived. No new replies allowed.