NEED ATOI HELP

hey,I'm in my first programming class and i cant figure out how to use atoi to change from a string to an integer.
please let me know what i'm doing wrong!!!!

1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>
using namespace std;
int main()
{
int num; 
string digits= "153";
num = atoi(digits.c_str());
cout<<num<<endl;

}
closed account (j3Rz8vqX)
include the <cstdlib>
still got errors. using microsoft visual c++ 2010 express if it matters
closed account (j3Rz8vqX)
I'm on gcc 4.7.1, no errors with the code below:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
    int num;
    string digits= "153";
    num = atoi(digits.c_str());
    cout<<num<<endl;
}


Output was:
153
Topic archived. No new replies allowed.