Join strings: revitalised: strlen and strcat : String Append « String « C / ANSI-C






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

1.Demonstrates how to put strings together using strcat
2.Get first and last name and print them together
3.Join strings
4.Append string to another string
5.Append string: strncatAppend string: strncat
6.String concatenate
7. Append substring to string: strncat
8. Append string: how to use strcat Append string: how to use strcat