openSuse 11 and atoi() function

Hi, ive ben trying to compile some C++ source code and have some problems with the atoi() function:

Running make:

error: ‘atoi’ was not declared in this scope

Is the atoi() function stashed in a strange header file, or perhaps the system doesn’t support it?

Any help would be much apreciated

#include <iostream>
#include <stdlib.h>

int main() {
        std::cout << atoi("42") << std::endl;
}

I compiled this code in SuSE 10.3. It works good. Here is my code


#include <iostream>
#include <stdlib.h>
int main()
{ std::cout << atoi("45") << std::endl; return 0; }

P. S. Try to put in the end of main a return value.:rolleyes:

<nitpicking>main() is the only function where a return statement is not required. (Besides void functions.) The compiler should, according to the standard, foresee the return value 0.</nitpicking>

your program misses one

#include <cstdlib>