The C++ method involves stringstreams and is similar to printing output and taking input.
I will explain the C method, since it's the shortest:
We have an std::string s which contains a decimal representation of an integer number. atoi() takes a 'const char *' and returns an int. To get the pointer, we call to std::string::c_str(). We pass this pointer to atoi(), and store atoi()'s return value into an int.
Done.
EDIT: Oh, right. atoi() returns 0 if the string was parsed as zero, or if the string was invalid.