C Programming
Computer Programming

C program to Copy a String



Write a program in C to Copy a String

\* C program to Copy a String *\

# include < stdio.h >
# include < conio.h >
int   main( )
{

char s1[100], s2[100], i ;
printf("\n Enter a string : ") ;
scanf("%s",s1) ;
for(i = 0; s1[i] != '\0'; ++i )
{
      s2[i] = s1[i] ;
}
s2[i] = '\0' ;
printf("\n Coppied String is : %s", s2 ) ;
return 0 ;

}

Output of Program :

Output of C program to Copy a String