Copying String
String is an array of characters whose last element is '0'. To copy a string means to copy every character from one character array to the other.
/*
http://www.ProbCOMP.com
String is an array of characters whose last element is '\0'. To copy a string means to copy every character from one character array to the
other.
*/
#include<stdio.h>
void main()
{
char str1[30],str2[30];
printf("enter a string of less tha 30 letters: ");
gets(str1);
for(int i=0;str1[i]!='\0';i++)
{
str2[i]=str1[i];
}
str2[i]='\0';
printf("\n string 2: %s",str2);
}
Download Program


