#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char str1[50],str2[50];
clrscr();
printf("\n enter 1st string:");
gets(str1);
printf("\n enter 2nd string:");
gets(str2);
printf("\n string after copying is :");
strcpy(str2,str1);
puts(str2);
getch();
}
OR
#include<stdio.h>
#include<conio.h>
void main()
{
char st1[100],st2[100];
int i=0;
clrscr();
printf("\n enter 1st string :");
gets(st1);
printf("\n enter 2nd string :");
gets(st2);
while(st2[i]!='\0')
{
st1[i]=st2[i];
i++;
}
printf("\n copied string is :");
puts(st2);
getch();
}
No comments:
Post a Comment