good night
I have a string that receives a value, with comma eg 11,222
How do I convert a string to comma point?
I'm trying to convert the string to float, however because of the comma does not handle values before the comma
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
float to_float(const std::string& str)
{
std::istringstream is(str) ;
float result;
result = ::strtod(str.c_str(), 0);
is >> result;
return result ;
}
float var4 = to_float(var3);
|
Last edited on
I just have to ask. What the heck is "virtgula"?
@helios: +18
Maybe I'm being too puritan, +14
Last edited on
Resolvido, usei
std::replace(var3.begin(), var3.end(), ',', '.');