Answers for "copy char array to char array c++"

C++
13

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
-1

vector to char array c++

std::vector<int> vec {1, 2, 3};
const int* = vec.data();
Posted by: Guest on March-05-2021

Browse Popular Code Answers by Language