1#include <iostream>
2#include <string>
3
4int main() {
5 std::string str = "123.4567";
6
7 // convert string to float
8 float num_float = std::stof(str);
9
10 // convert string to double
11 double num_double = std::stod(str);
12
13 std:: cout<< "num_float = " << num_float << std::endl;
14 std:: cout<< "num_double = " << num_double << std::endl;
15
16 return 0;
17}