<string.h> Functions

C strcpy()

C strcpy()

The function prototype of strcpy() is:

char* strcpy(char* destination, const char* source);
  • The strcpy() function copies the string pointed by source (including the null character) to the destination.
  • The strcpy() function also returns the copied string.

The strcpy() function is defined in the string.h header file.


Example: C strcpy()

Output

C programming

Note: When you use strcpy(), the size of the destination string should be large enough to store the copied string. Otherwise, it may result in undefined behavior.