Join strings: revitalised: strlen and strcat
#include <stdio.h>
#include <string.h>
#define STR_LENGTH 40
void main() {
char str1[STR_LENGTH] = "String in C";
char str2[STR_LENGTH] = ",String in C";
if(STR_LENGTH > strlen(str1) + strlen(str2)) /* Enough space ? */
printf("\n%s\n", strcat(str1, str2) ); /* yes, so print joined string */
else
printf("\n no enough room.");
}
Related examples in the same category