C Program to concatenate two strings

This example implements strcat() function which will help to concatenate any two given strings. This function will concatenate two strings into a single string and returns the result of the concatenated string.

Before moving on to the code you have to make sure that you have a priori knowledge of the following topics to understand this example in more detail.

Code:

#include<stdio.h>
#include<string.h>
int main()
{
	char s1[50] = {"Hello"};
	char s2[50] = {"World"};
	strcat(s1, s2);
	printf("The output after the concatenation is %s", s1);
}

The above code will display its output as below.

Output:

The output after the concatenation is HelloWorld

SHARE C Program to concatenate two strings

You may also like...

Leave a Reply

Your email address will not be published.

Share