C program to copy one string to another

Write a C program to get a string from the user, storing it in a character array and copy the string to another character array, finally print the character array.

C Implementation:


#include <stdio.h>
int main(void) {
 char s[50],v[50];
 int i;
 i=0;
 printf("Enter a string to copy:\n");
 scanf("%s",s);
 while(s[i]!='\0')
 {
  v[i]=s[i];
  i++;
 }
 v[i]='\0';
 printf("copied string is %s",v);
 return 0;
}

Output:

Enter a string to copy:
www.coderegister.co.in

copied string is www.coderegister.co.in