Answers for "write string into char array c++"

C++
12

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());
Posted by: Guest on August-27-2020
0

how to input a string into a char array cpp

strcpy(my_array, my_string.c_str());
Posted by: Guest on August-26-2020

Browse Popular Code Answers by Language