std::string myWord = "myWord";
char myArray[myWord.size()+1];//as 1 char space for null is also required
strcpy(myArray, myWord.c_str());
const char *array = tmp.c_str(); //For const char array
char *array = &tmp[0]; // If you need to modify the array
std::string strCoffee = "Nescafe";
const char *charCoffee = strCoffee.c_str();
Code Example |
---|
Cpp :: cpp vector2 |
:: |
Cpp :: |
Cpp :: create copy constructor c++ |
:: |
:: |
:: concat two vectors c++ |
:: even and odd sum in c++ |
:: |
Cpp :: |
Cpp :: |
Cpp :: |
:: cpp when use size_t |
:: |
Cpp :: getline(cin string) not working |
Cpp :: |
:: 2d vector in cpp |
:: |
Cpp :: convert int to string in c++ |
Cpp :: c++ Program to check if a given year is leap year |
:: |
Cpp :: how to initialize 2d array with values c++ |
Cpp :: |
:: |
Cpp :: |
Cpp :: |
:: add matic mainnet to metamask mobile |
:: fill two dimensional array c++ |
:: |
:: |