Answers for "double to string c++"

C++
4

double to string c++

std::ostringstream strs;
strs << dbl;
std::string str = strs.str();
Posted by: Guest on March-25-2020
5

to_string c++

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

int main ()
{
  std::string pi = "pi is " + std::to_string(3.1415926);
  std::string perfect = std::to_string(1+2+4+7+14) + " is a perfect number";
  std::cout << pi << '\n';
  std::cout << perfect << '\n';
  return 0;
}
Posted by: Guest on June-04-2020

Browse Popular Code Answers by Language