C program to copy the elements of one string to the another
Refer to the following pages to learn the basics before learning this example.
This program will ask the user to enter a string in one of the variables and then copies the variable into another variable. The program will display the second variable to illustrate the activities perform within the program. The output of the second variable will be the same as that of the first variable as we have copied the element of the first string into the second.
char n1, n2;
puts("Enter the string: ");
strcpy(n2, n1);// copies the elements of the first string to the second
puts(n2);// displays the elemnts of the second string
The above code will display its output as below.