Skip to main content

Concatenation of String Example in C

1 min read Updated June 30, 2026
Share:
On this page (7sections)

About this program

This is an example program in c string example programs. Read the concept first: C Strings in C Programming, then study the code and output below.

Concatenation of string Definition:

In computer programming, string concatenation is the operation of joining two character strings end-to-end.

Concatenation of string Explanation:

For example, the strings “snow” and “ball” may be concatenated to give “snowball”.
For example, the following expression uses the ”+” symbol as the concatenation operator to join two strings: “Hello, ” + “World”;, and has the value “Hello, World”.

Example Concatenation of string Program:

/* Example Program For Concatenation of string In C Programming Language
  little drops @ thiyagaraaj.com
  Coded By:THIYAGARAAJ MP       */

// Header Files
#include<stdio.h>
#include<conio.h>

void main()
{
	int i,j;
	char string1[20];
	char string2[20];
	char string[100];
	
	clrscr();
	printf("Enter Sring1: ");
	scanf("%s",string1);
	printf("Enter Sring2: ");
	scanf("%s",string2);
	for(i=0;string1[i]!='\0';i++)
	string[i]=string1[i];
	string[i]=' ';
	for(j=0;string2[j]!='\0';j++)
	string[i+j+1]=string2[j];
	string[i+j+1]=' ';
	printf("%s",string);
	
	getch();
}

Sample Output:

Enter Sring1: Hello,

Enter Sring2: World

The Concatenated string is: Hello, World

Learn the concept first, then study the code:

Frequently Asked Questions

What does this C program do?
It is a C example program that demonstrates Concatenation of String, including the complete source code and the expected sample output.
How do I compile and run this C program?
Save the code in a `.c` file, compile it with `gcc filename.c -o program`, then run it with `./program` (or `program.exe` on Windows).
What concepts does this example use?
This example uses loops to iterate over data, arrays and reading user input, illustrating a common pattern in C programming.

Related Tutorials

Search tutorials