I have searched on the internet for a 'working' double to char* does anyone have any idea? I need to pass the string to a function that takes a char* as an argument.
Elixir42
0
Junior Poster in Training
Recommended Answers
Jump to PostYou could try something like this:
#include <iostream> #include <sstream> #include <limits> #include <iomanip> std::string double_to_string(const double value) { std::ostringstream stream; // Go for maximum precision and take into account that converting could fail. if (!(stream << std::setprecision(std::numeric_limits<double>::digits10) << value)) { // Possibly throw an exception instead. …
Jump to PostC++11:
std::to_string()
http://en.cppreference.com/w/cpp/string/basic_string/to_string
All 6 Replies
Gonbe
32
Newbie Poster
vijayan121
1,152
Posting Virtuoso
Elixir42
0
Junior Poster in Training
Elixir42
0
Junior Poster in Training
NathanOliver
429
Veteran Poster
Featured Poster
Elixir42
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.