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
1// example
2char sczName[] = {"Jakes"};
3std::string strName = std::string(sczName);
4
5/* SYNTAX
6#include <string>
7std::string(<char-to-convert>)
8*/
1#include <iostream>
2using namespace std;
3
4int main()
5{
6 char c = 'l';
7 string str;
8 str.push_back(c);
9}