strcpy() function in C by R4R Team

-strcpy() is a string function that are able to copy one string into the other string.
-It is predefined in string.h header file.
Syntax-
strcpy(string1,string2)
-It copy content of string2 in string1

program-

#include< stdio.h>
#include< string.h>
int main()
{
char s1[20],s2[20];
//input of string
printf("Enter first string\n");
scanf("%s",&s1);
//copy s1 into s2
strcpy(s2,s1);
printf("Now second string is %s",s2);
}


output-

Enter first string
Mystring
Now second string is Mystring

-In this program, we take an input of the string, and pass in strcpy() function so this function copy the input string in s2 string.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!