Search



Wednesday, 4 March 2015

Concatenate a String without using strcat

#include <stdio.h>
#include<conio.h>
void main()
{ char s1[100], s2[100], i, j;
printf("Enter first string: ");
scanf("%s",s1);
printf("Enter second string: ");
scanf("%s",s2);
for(i=0; s1[i]!='\0'; ++i);
{ for(j=0; s2[j]!='\0'; ++j, ++i)
{ s1[i]=s2[j];
}
}
s1[i]='\0';
printf("After concatenation string 1 =  %s",s1);
getch();
}

No comments:

Post a Comment

Guys if you think something is wrong or should be edit than please do comment.