strcpy(): String Copy in C (String Handling Function)

String handling function strcpy() is used to copy content of one string variable to another string variable i.e. strcpy(string2, string1) copies content of string1 to string2.

strcpy() Syntax

strcpy ( string2, string1);

strcpy() Program

int main()
 char str1[30], str2[30];

 printf("Enter string:\n");
 strcpy(str2, str1);
 printf("Coped string is: %s”, str2);

 return 0;

strcpy() Program Output

Enter string:
Welcome to C↲
Copied string is: Welcome to C

Note: ↲ indicates ENTER is pressed.