strcpy ( ) functions:
The function copies the content of one string to another..The format of strcpy( ) is strcpy(s2,s1).
Where,
s1 is a source string.
s2 is destination string.
s1 is copies to s2.
In many programs we copy the content of one string to an another.Given below is an example which is based on strcpy( ) function.
Program:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main( )
{
char ori[20],dup[20];
printf("Enter your name");
gets(ori);
strcpy(dup,ori);
printf("original of string =%s",ori);
printf("\nDuplicate string=%s",dup);
}
OUTPUT:
Enter your name :SACHIN
original string :SACHIN
Duplicate string :SACHIN
Explanation :
In the above example we have declared two array namely ori[20] and dup[20].the function strcpy( ) copies the characters of ori[ ] to dup[ ].The characters are copied one by one form the source string (ori [20] ) to destination string (dup[20]).