C strcpy() function

strcpy() function in C is used to copy the string to another character array. This function makes changes to the original destination string and returns the pointer to the destination string.

Basic Syntax

char* strcpy(char* dest, const char* src);

And the parameters are:

destThis parameter specifies the destination character array in which string should be copied
srcThis specifies string to be copied

Return Value

This function returns the pointer to the destination string dest.


Following are the examples for strcpy() function in C.

Example 1

The output should be:

dest1: www.CrazyGeeks.org
dest2: Welcome

Example 2

The output should be:

str2: www.CrazyGeeks.org
str3: www.CrazyGeeks.org


Please enter your comment!
Please enter your name here