C Program to Copy one string into other with using library function
Copy One String Into Other Using Library Function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
#include<stdio.h> #include<string.h> int main() { char str1[100]; char str2[100]; printf("\nEnter the String 1 : "); gets(str1); strcpy(str2, str1); printf("\nCopied String : %s", str2); return (0); } |
Output :
1 2 |
Enter the String 1 : c4learn Copied String : c4learn |
Explain me ?
- Copy “str1” into “str2”.
- Result will be stored in “str2”
- strcpy functions is included in Header File : string.h
Functions Required :