Function to copy string ( Iterative and Recursive ) | Iterative CPP Program to copy one String to another . ; Function to copy one string to other assuming that other string has enough space . ; Driver function
#include <bits/stdc++.h> NEW_LINE using namespace std ; void myCopy ( char s1 [ ] , char s2 [ ] ) { int i = 0 ; for ( i = 0 ; s1 [ i ] != ' \0' ; i ++ ) s2 [ i ] = s1 [ i ] ; s2 [ i ] = ' \0' ; } int main ( ) { char s1 [ 100 ] = " GEEKSFORGEEKS " ; char s2 [ 100 ] = " " ; myCopy ( s1 , s2 ) ; cout << s2 ; return 0 ; }