Encoders
Hub for Computer Whizzes Register to join us

Encoders > More... > C > Program

/* Function strcat(s,t) to concatenate t to the end of s,
   s must be big enough. */

#include <stdio.h>

void strcat(char s[], char t[]);

main()
{
        char a[100]="hello world", b[]="apple";
	strcat(a,b);
        printf("%s\n",a);
}

void strcat(char s[], char t[])
{
	int i=0,j=0;
	while(s[i]!='\0')
		i++;
	while((s[i++]=t[j++])!='\0')
		;
}