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
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- 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 Keyword or not
- C++ Program to Convert String to Integer
- C++ Program to compare two string using pointers
- C Program to Check if a Given String is Palindrome
- Program to Reverse a String using Pointers
- Program to extract words from a given String
- Program to duplicate Vowels in String
- Program to print all substrings of a given 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 email@example.com. 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.