I am working on a C++ project for a Vex Robot, I am using a function that takes a const char[]
but for showing an integer, there is no such function that converts to const char[]
, so is there a way to do that. All the search results showed how to convert to const char*
and by the way "string" is of type const char[]
.
EDIT: I also need to covert the string to concatenate tow strings (but ended up just coverting both strings to std::string and then back to const char[])
With std::string
there is the function c_str()
(with the synonym data()
since C++11) to get a pointer to the underlying null-terminated character array:
std::string const myString{"stackoverflow"};
const char* cstr = myString.c_str();
const char* data = myString.data();