Hi All,
I am a beginner of C Programming. I wrote a strcat function of my own. Please let me know your comments:
Code:
#include <stdio.h>
void mystrcat(char *, char *, char *);
int main()
{
char s1[] = "Hello";
char s2[] = "World";
char catstring[sizeof(s1) + sizeof(s2)];
mystrcat(s1, s2, catstring);
printf("%s", catstring);
getch();
}
void mystrcat(char *s1, char *s2, char *catstring)
{
int i=0, k=0;
while(*s1 != '\0')
{
catstring[k] = *s1;
k++;
s1++;
}
while(*s2 != '\0')
{
catstring[k] = *s2;
k++;
s2++;
}
catstring[k] = '\0';
}