You can do this using stringstream, or atoi :)
http://www.cplusplus.com/reference/sstream/stringstream/stringstream/
http://www.cplusplus.com/reference/cstdlib/atoi/
By the way, you should probably put your code between code tags [ code] [/ code] (but without the spaces) that way others can easily look at your code and refer to lines that need changing.