### strcpy -- Copy Strings

Format

>     #include <string.h>
>     char *strcpy(char *string1, const char *string2);

Language Level: ANSI, POSIX, XPG4
strcpy copies string2, including the ending null character, to the location specified by string1.

strcpy operates on null-terminated strings. The string arguments to the function should contain a null character (\0) marking the end of the string. No length checking is performed. You should not use a literal string for a string1 value, although string2 may be a literal string.

Return Value
strcpy returns a pointer to the copied string (string1).

Example
This example copies the contents of source to destination.

    #include <stdio.h>
    #include <string.h>

    #define SIZE    40

    int main(void)
    {
      char source[ SIZE ] = "This is the source string";
      char destination[ SIZE ] = "And this is the destination string";
      char * return_string;

      printf( "destination is originally = \"%s\"\n", destination );
      return_string = strcpy( destination, source );
      printf( "After strcpy, destination becomes \"%s\"\n", destination );
      return 0;

      /*******************************************************************
         The output should be similar to:

         destination is originally = "And this is the destination string"
         After strcpy, destination becomes "This is the source string"
      *******************************************************************/
    }

strcat -- Concatenate Strings
strchr -- Search for Character
strcmp -- Compare Strings
strcspn -- Compare Strings for Substrings
strdup -- Duplicate String
strncpy -- Copy Strings
strpbrk -- Find Characters in String
strrchr -- Find Last Occurrence of Character in String
strspn -- Search Strings
wcscpy -- Copy Wide-Character Strings
wcsncpy -- Copy Wide-Character Strings
<string.h>