1

I want to convert the string into a float array They are saved as double strings Thanks for your help

string str ="7.13566982194977e-15,1.639519203260036e-43,4.149314136725479e-8,7.987401246651457e-44,7.11674964700695e-15,1.639519203260036e-43,4.515206005147025e+27"

std::vector<float> result 
Yksisarvinen
  • 18,008
  • 2
  • 24
  • 52
bakboem
  • 534
  • 4
  • 12

1 Answers1

2
std::istringstream(str);     // #include <sstream>
std::string s;
std::vector<float> result;
while (std::getline(str, s, ','))
{
    float f = atof(s.c_str());
    result.push_back(f);
}
selbie
  • 100,020
  • 15
  • 103
  • 173