strcpy C Library Function

The function char *strcpy(char *destination, const char *source); copies the string pointed by source into the string pointed by destination including the null character('\0').

Function prototype of strcpy

char *strcpy(char *destination, const char *source);
  • destination : This is pointer to a string where the content is to be copied.
  • source : This is pointer to a string from where data to be copied.

Return value of strcpy

This function returns a pointer to destination string.

C program using strcpy function

The following program shows the use of strcpy function to copy a string into another string.

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

int main ()
   char source[100], destination[100];

   printf("Enter source string\n");
   strcpy(destination, source);
   printf("Destination string : %s\n", destination);

Enter source string
Destination string : TechCrashCourse