Extracting decimal numbers from a string

Hello,

Extracting integers from a string is trivial, but I am unable to find a function or code that will extract decimal numbers from a string.

I have a string that looks something like this:
" Asdf 1 1.3825 4.0000 12.0000 1.9133 0.1853 0.9000 1.1359 4.0000 "


Any tips on extracting the numbers (in decimal form) and storing them in a vector?
1
2
3
double d;
std::cin >> d;
std::cout << d;
12.75
12.75
That code does not convert strings to decimals, I'm looking for a way to extract a double from a string.
Last edited on
You could put that string into a stringstream then treat it like cin and extract the values that way.
Last edited on
Sorry, did not notice that you need to convert from already stored string.
You can use stringstreams: http://ideone.com/ldzqM2
Last edited on
Topic archived. No new replies allowed.