C strcpy()

The strcpy() function copies the contents of str2 into str1. str2 must be a pointer to a null-terminated string. The strcpy() function returns a pointer to str1.

If str1 and str2 overlap, the behaviour of strcpy() is undefined.

strcpy() Syntax

Following is the syntax of the strcpy() function :

char *strcpy(char *str1, const char *str2);

strcpy() Example

Following code fragment copies hello into string str :

char str[80];
strcpy(str, "hello");

C Online Test

« Previous Chapter Next Function »

Like/Share Us on Facebook 😋