Horje
convert string to char c++ Code Example
string to char array c++
std::string myWord = "myWord";
char myArray[myWord.size()+1];//as 1 char space for null is also required
strcpy(myArray, myWord.c_str());
convert string to char c++
// "std::string" has a method called "c_str()" that returns a "const char*"
// pointer to its inner memory. You can copy that "const char*" to a variable
// using "strcpy()".

std::string str = "Hello World";
char buffer[50];

strcpy(buffer, str.c_str());

std::cout << buffer;	//Output: Hello World

//POSTED BY eferion ON STACK OVERFLOW (IN SPANISH).




8

Related
removing a character from a string in c++ Code Example removing a character from a string in c++ Code Example
range of long long in c++ Code Example range of long long in c++ Code Example
string to char array c++ Code Example string to char array c++ Code Example
input a string in c++ Code Example input a string in c++ Code Example
conda list envs Code Example conda list envs Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13