1std::string myWord = "myWord";
2char myArray[myWord.size()+1];//as 1 char space for null is also required
3strcpy(myArray, myWord.c_str());
1// "std::string" has a method called "c_str()" that returns a "const char*"
2// pointer to its inner memory. You can copy that "const char*" to a variable
3// using "strcpy()".
4
5std::string str = "Hello World";
6char buffer[50];
7
8strcpy(buffer, str.c_str());
9
10std::cout << buffer; //Output: Hello World
11
12//POSTED BY eferion ON STACK OVERFLOW (IN SPANISH).
13