This C program is used to copy the string by using the library function strcpy().
char source = "C Program";
printf("Source string: %s\n", source);
printf("Destination string: %s\n", destination);
Output of program:
Source string: C Program
Destination string: C Program
This program is used to copy a character array's value from one character to another. So first of all, you have to include the stdio header file using the include preceding by # which tells that the header file needs to be process before compilation, hence named preprocessor directive. Also you have to include the string.h header file. The string.h header classifies one variable type, one macro, and various functions to manipulate arrays of characters within your program.
Then you have to define the main() function and it has been declared as void since no return type is associated with it. The inside the main() function, you have to take one character array name source and initialize with the string C Program. Then you have to again take another character array name destination which has not been initialized. Now you have to implement the strcpy() function, which is the C library function strcpy(dest, src) copies the string pointed to by the src to dest.
The printf() function is then use to display the strings Source string: %s\n and operation performed after strcpy() is used in the form of output. The printf() is used twice first for source, second for displaying destination.