Extract keys from a string

Hello,

Supposing to have this string:

std::string str = "Func(123.6,6565.3,342.2,76.04)"
How can I extract single values from it and put them in single float variables using stringstream or something else?
Last edited on
This is by no means a finished solution, but this is more than enough to get you close enough to fiddle with it.

1
2
3
4
5
6
7
8
9
10
11
12
std::string funcstr = "func(123.45,643.21,34.32)";
std::stringstream sstrm;
sstrm  << funcstr;
char buff[20];
float arg1(0.0);
sstrm.getline(buff, funcstr.length(), '(');
while(sstrm.getline(buff, funcstr.length()-1, ','))
{
	std::stringstream floatstream;
	floatstream << buff;
	floatstream >> arg1;
}
Topic archived. No new replies allowed.