strcpy( ) function in C

strcpy( ) function in C copies the contents of one string into another. The base addresses of the source and target strings should be supplied to this function

Example of strcpy() function

main( ) 
{ 
 char source[ ] = "Sayonara" ;
char target[20] ; 
 strcpy ( target, source ) ; 
 printf ( "\nsource string = %s", source ) ; 
 printf ( "\ntarget string = %s", target ) ; 
} 

And here is the output…

source string = Sayonara
target string = Sayonara

Leave a Comment