to float convert c++ code example
Example 1: int to float c++
int a = 3;
float b = (float)a;
Example 2: c++ std string to float
std::string num = "0.6";
double temp = ::atof(num.c_str());
std::cout << temp << std::endl;
// Output: 0.6
int a = 3;
float b = (float)a;
std::string num = "0.6";
double temp = ::atof(num.c_str());
std::cout << temp << std::endl;
// Output: 0.6