Wednesday, September 17, 2008

CONCATENATION OF TWO STRINGS in c programming language

52. CONCATENATION OF TWO STRINGS

void main()
{
int i=0,j=0;
char str1[20],str2[20];
clrscr();
puts("Enter first string");
gets(str1);
puts("Enter second string");
gets(str2);
printf("Before concatenation the strings are\n");
puts(str1);
puts(str2);
while(str1[i]!='\0')
{
i++;
}
while(str2[j]!='\0')
{
str1[i++]=str2[j++];
}
str1[i]='\0';
printf("After concatenation the strings are\n");
puts(str1);
getch();
}

No comments:

Post a Comment

Thanks to given comments.......

My Blog List