C Program Of Strcpy() Function

C Program Of Strcpy() Function

#include<stdio.h>
#include<stdio.h>

main()
{

char str1[20];
char str2[20];

printf("Enter string 1:\n");     //user give message and
scanf("%s",str1);     //input taken from user/keyboard

printf("Enter string 2:\n");     //user give message and
scanf("%s",str2);    //input taken from user/keyboard

printf("string 1 is '%s' and string 2 is '%s'\n",str1,str2);


strcpy(str1,str2);   //if string 2 copied to string 1 then previous value in string 1 is overwriten by string 2.


printf("Aftre copy string 1 is '%s' and string 2 is '%s'\n",str1,str2);    //print string 1 and two after copy to each other.

}

Related Posts