strcat function : Concat two Strings in C >> String Operations



strcat function >> Concat two Strings >>  String Operations

What strcat Actually does ?
  1. Function takes 2 Strings / Character Array as Parameter
  2. Appends second string at the end of First String.

Parameter Taken 2 Character Arrays / Strings
Return Type Character Array / String

Syntax :

char* strlen ( char * s1, char * s2);


Ways of Using Strcat Function :
Way 1 : Taking String Variable as Parameter
           char str1[20] = “Don” , str2[20] = “Bosqo”;
           strcat(str1,str2);
           puts(str1);
Way 2 : Taking String Variable which is Already Initialized using Pointer
           char *str1 = “Ind”,*str2 = “ia”;
           strcat(str1,str2);                     // Result stored in str1
           puts(str1);                             // Result : India
Way 3 : Writing Function in printf Statement

           printf(“nString :  “, strcat(“Ind”,”ia”));