Home >>C String functions >C strcpy() function

C strcpy() function

C strcpy() function

Strcpy() function copy contents of one string to another string.

Syntax:
 Strcpy(str1,str2)

Note:- Here str is given string.

Parameters:-

It takes strings as parameter.

Return type:-

It returns modified string.

Example-1

#include <stdio.h>
#include <string.h>
int main( )
{
   char source[ ] = "copy the content" ;
   char target[20]= "" ;
   printf ( "\nsource string = %s", source ) ;
   printf ( "\ntarget string = %s", target ) ;
   strcpy ( target, source ) ;
   printf ( "\ntarget string after strcpy( ) = %s", target ) ;
   return 0;
}

Output:
Target string after strcpy()=copy the content

No Sidebar ads