c++ string 转double

时间:2023-12-27 10:40:19

#include <iostream>
#include <sstream> //使用stringstream需要引入这个头文件
using namespace std;

Type stringToNum(const string& str)
{
istringstream iss(str);
Type num;
iss >> num;
return num;
}

int main()

{

string sharp_fn_array = "0.35684";

volt_min = stringToNum<double>(sharp_fn_array);
cout << volt_min << endl;

}