@StormHasHe: It would be better if you didn't offer advice on topics you clearly have no idea about.
In C++03, it's not that straightforward, the best idea I came up with is
http://ideone.com/EJ7LQIf you can use C++11, you can use functions like stoi and get something like this
http://ideone.com/47LGSI admit, neither is very reader-friendly, but it'd be trivial to write your own template function that'd try to convert strings from an istream.