#include<stdio.h>
void astrcat(char s[], char t[]); //to concatenate two string
main()
{
int i=0,p=0,q=0,c;
char s[100],t[100];
while((c=getchar())!='\n')
s[p++]=c;
while((c=getchar())!='\n')
t[q++]=c;
astrcat(s,t);
while(s[i]!='\0')
printf("%c",s[i++]);
return 0;
}
void astrcat(char s[],char t[])
{
int i, j;
i = j = 0;
while (s[i] != '\0') /* find end of s */
i++;
while ((s[i++] = t[j++]) != '\0') /* copy t */
;
}
The above code works fine but show some additional symbols after the concatenated string. I've checked it several times but am unable to spot the error. Pls run this code on ur system and let me know where lies the error.
Thanks in advance
R.S.V.P. :confused: