1char str[80];
2strcpy(str, "these ");
3strcat(str, "strings ");
4strcat(str, "are ");
5strcat(str, "concatenated.");
1// null protected
2char* strconcat(char *str1, const char *str2)
3{
4 char *str = NULL;
5 size_t len1 = 0;
6 size_t len2 = 0;
7
8 if (str1)
9 len1 = strlen(str1);
10 if (str2)
11 len2 = strlen(str2);
12 if (!(str = calloc(sizeof(char), (len1 + len2 + 1))))
13 return NULL;
14 if (str1)
15 memcpy(str, str1, len1);
16 if (str2)
17 memcpy(str + len1, str2, len2);
18 return (str);
19}