In this example, we take on string input and copy that string into another variable with help of strcpy() function.
strcpy() function is used copy string and it's a in-built function provided by c programming. We must include <string.h> heder file to use this function.
Example :
#include <stdio.h>
#include <string.h>
int main()
{
char Str[100];
char Dest[100];
printf("\n Please Enter any String : ");
gets(Str);
strcpy(Dest, Str);
printf("Source string: %s \n", Str);
printf("Destination string: %s \n", Dest);
return 0;
}
Output :
Please Enter any String : Hello World!
Source string: Hello World!
Destination string: Hello World!
Ask anything about this examples