how to convert a string into int

Hi, well, one of the things that I have to do is prompt the user to enter a number between 0 and 10,000, but I must accept user's input as string, so I have to make a function thattakes a string as an argument and converts it into an integer value.
I tried to use static_cast<> but is doesn't let me do it. I guess that I wrong. anyone could give me any suggestion please. thanks for everything.
try stringstreams
eg:
1
2
3
4
5
string sample = "123";
stringstream ss(sample);
int result;
ss >> result;
//result now == 123 
thanks a lot, I'll try
Also

1
2
3
#include <boost/lexical_cast.hpp>

int result = boost::lexical_cast<int>( "123" );


works.
Topic archived. No new replies allowed.