C++ examples for Data Type:char array
Copy a string using strcpy() function
#include <iostream> #include <cstring> //for strcpy() using namespace std; int main()// ww w. jav a 2 s .c o m { char str1[] = "this is a test this is atest"; const int MAX = 80; //size of str2 buffer char str2[MAX]; //empty string strcpy(str2, str1); //copy str1 to str2 cout << str2 << endl; //display str2 return 0; }