I've been trying to convert a simple string to a float, but I'm having no luck with it. this is what I've got at the moment:
int main()
{
float value;
std::string stringNum = "0.5";
std::istringstream(stringNum) >> value;
return 0
}
but I'm getting this error:
Error 2 error C2440: '<function-style-cast>' : cannot convert from 'std::string' to 'std::istringstream' c:\users\administrator\desktop\Test\main.cpp 12
can anyone give me some guidance here on how to just simply convert the string to a float?
Thanks
std::istringstream{std::string{"0.5"}} >> value ;std::istringstream{"0.5"} >> value;