get int out of string with spaces

How can I extract the number out of the string:

string my_sting = "item code = 9";

I want to get the '9' out of the string and store it in a separate int variable.
I tried using sstream library and was having trouble.
If you are using a C++11 compiler and the regex library is available:

You can use the regex library to "extract" the number as a match, then use a C++11 function std::stoi() to actually convert the match to an int.
Topic archived. No new replies allowed.