#include <stdio.h>
#include <stdlib.h>
void concat(char *p, char *str1, char *str2)
{
int i,j;
for (i = 0; str1[i]; i++) {
p[i] = str1[i];
}
for (j = 0; str2[j]; j++) {
p[i++] = str2[j];
}
p[i] = 0;
}
int main(void)
{
char str1[10] = "hello", str2[10] = "world!!!", *p;
p = (char *)malloc(sizeof(char) * 20);
if (p == (char *)NULL) {
fprintf(stderr, "malloc fail!!!\n");
exit(1);
}
concat(p, str1, str2);
printf("%s \n", p);
}