How to convert a string type variable into an integer?

Hi everybody!
Does anybody know any function that converts a string type variable to an integer type.For eaxample:

string year="2011";
int number=function(year);
so it returns
number=2011;

I just want the name of the function and the standard library that contains it.
Thank you!
This has to be one of the most FAQ's in C++ these days. The Net can answer you in seconds:

http://tinyurl.com/6x9u53s

Similar posts are abundant, even in this forum.
Thank you guys , but it seems tha atoi() function accepts only char type variable.I need a function that has for argument a string type variable.
For axample:
atoi() works with char year[4]="2011" but it doesn't take as argument string year="2011" .
Last edited on
I just find a way using istringstream type , defined at <sstream> library.
Or it can be used used like this :
string year="2011";
int y=atoi(year.c_str());
y=2011;
Topic archived. No new replies allowed.