C++ char array Copy a string using strcpy() function

Description

C++ char array Copy a string using strcpy() function

#include <iostream>
#include <cstring>                     //for strcpy()
using namespace std;
int main()/*from   www.j ava 2 s.  c  om*/
{
   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;
}



PreviousNext

Related