C program to copy a string.

 

01 #include<stdio.h>
02
03 void stringCopy(char[],char[]);
04 int main()
05 {
06 char str1[100],str2[100];
07 printf("Enter any string: ");
08 gets(str1);
09 stringCopy(str1,str2);
10 printf("After copying: %s",str2);
11
12 return 0;
13 }
14 void stringCopy(char str1[],char str2[])
15 {
16 int i=0;
17 while(str1[i]!='')
18 {
19 str2[i]=str1[i];
20 i++;
21 }
22 str2[i]='';
23 }
 
 
OUTPUT :

Enter any string: MYWorld

After copying: MYWorld

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *