You can’t do it directly. There are a number of ways to do it:
-
Use a
std::stringstream
:std::ostringstream s; s << "(" << c1 << ", " << c2 << ")"; storedCorrect[count] = s.str()
-
Use
boost::lexical_cast
:storedCorrect[count] = "(" + boost::lexical_cast<std::string>(c1) + ", " + boost::lexical_cast<std::string>(c2) + ")";
-
Use
std::snprintf
:char buffer[256]; // make sure this is big enough!!! snprintf(buffer, sizeof(buffer), "(%g, %g)", c1, c2); storedCorrect[count] = buffer;
There are a number of other ways, using various double-to-string conversion functions, but these are the main ways you’ll see it done.