145. Program to concatenate two strings.
#include<stdio.h>
char
s1[10],s2[10],len1,len2,i,j;
void
main()
{
printf("Enter string 1 : ");
scanf("%s",s1);
printf("Enter string 2 : ");
scanf("%s",s2);
for(len1=0;s1[len1];len1++);
for(len2=0;s2[len2];len2++);
if(sizeof(s1)>=len1+len2+1)
{
for(i=len1,j=0;s2[j];i++,j++)
{
s1[i]=s2[j];
}
s1[i]=s2[j];
}
printf("String 1 : %s\n",s1);
printf("String 2 : %s\n",s2);
}
Comments
Post a Comment