We can use inbuilt strcpy() function to copy one string to other but here, this program copies the content of one string to another manually without using strcpy() function.
Approach : Here we are giving one string in input and then with the help of for loop we transfer the content of first array to the second array.
Error : If destination string length is less than source string, entire string value won’t be copied into destination string.
For example, consider destination string length is 20 and source string length is 30. Then, only 20 characters from source string will be copied into destination and remaining 10 characters will be truncated.
string s1 : GeeksforGeeks String s2 : GeeksforGeeks
- strcpy in C/C++
- Why strcpy and strncpy are not safe to use?
- Program to copy the contents of one array into another in the reverse order
- C program to copy contents of one file to another file
- C program to print a string without any quote (singe or double) in the program
- Print substring of a given string without using any string function and loop in C
- Program to Encrypt a String using ! and @
- C Program to Check if a Given String is Palindrome
- C program to check if a given string is Keyword or not
- Program to Reverse a String using Pointers
- C++ Program to compare two string using pointers
- Program to print all substrings of a given string
- Program to extract words from a given String
- Program to remove vowels from a String
- C program to find the length of a string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.