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
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- 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 @
- Program to remove vowels from a String
- C Program to Check if a Given String is Palindrome
- C++ Program to Convert String to Integer
- Program to extract words from a given String
- Program to print all substrings of a given string
- Program to duplicate Vowels in String
- C++ Program to compare two string using pointers
- C program to find the length of a string
- C program to check if a given string is Keyword or not
- Program to Reverse a String using Pointers
- Python program to check if a string is palindrome or not
- Program to check if first and the last characters of string are equal
- Program to replace every space in a string with hyphen
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.