In this tutorial, we are going to write a C program to concatenate strings in C Programming with practical program code and step-by-step full complete explanation.

C program to concatenate strings


C Program to concatenate strings.

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

void main()
{
    int i,j,k;
    char first_name[10]={'A','N','A','N','D','A'};
    char second_name[10]={'M','U','R','U','G','A','N'};
    char last_name[10]={'S','E','L','V','A','R','A','J'};
    char name[30];

    for(i=0;first_name[i]!='\0';i++)
        name[i]=first_name[i];

    name[i]=' ';

    for(j=0;second_name[j]!='\0';j++)
        name[i+j+1]=second_name[j];

    name[i+j+1]=' ';

    for(k=0;last_name[k]!='\0';k++)
        name[i+j+k+2] = '\0';

    printf("\n\n");
    printf("%s\n",name);
}


Output

 
ANANDA MURUGAN