String Concatenation in C Program

ஒரு string variable-உடன் மற்றொரு string variable-ன் value-வை strcat() என்ற function-ஐ பயன்படுத்தி ஒன்றாக சேர்ப்பது string concatenation ஆகும்.

Syntax for Concatenation

strcat(string1, string2);

Example

#include<stdio.h>
#include<conio.h>
#include<string.h>

int main(){
    char str1[]="welcome to";
    char str2[]= "c program";

    printf("\n Before Concatenation, str1 value is %s ",str1);

    strcat(str1,str2); //copy from str2 to str1
    printf("\n After Concatenation, str1 value is %s ",str1);


return 0;
}

Output:

Before Concatenation, str1 value is welcome to
After Concatenation, str1 value is welcome to c program

Comments

Ramya 23rd July,2023 09:21 am
C program all information in Tamil