从字符串中获取由逗号隔开的浮点数

废话不说,上代码

#include <algorithm>
#include <sstream>
#include <string>
using namespace std;

float fNum[2];
string str = "123, 345.6";
replace(str.begin(), str.end(), ',', ' ');
istringstream iss(str);
for(int i=0; i<2; i++)
{
	iss >> fNum[i];
}