[Solved] how can i pass from char[i] to a double? [closed]


You can use functions std::stringstream from sstream or strtod from cstdlib or stod (If you are using C++11) as per your need.

Quoting example from cplusplus.com

// stod example
#include <iostream>   // std::cout
#include <string>     // std::string, std::stod

int main ()
{
  std::string orbits ("365.24 29.53");
  std::string::size_type sz;     // alias of size_t

  double earth = std::stod (orbits,&sz);
  double moon = std::stod (orbits.substr(sz));
  std::cout << "The moon completes " << (earth/moon) << " orbits per Earth year.\n";
  return 0;
}

2

solved how can i pass from char[i] to a double? [closed]