C Program to Concatenate Two Strings

To understand this example, you should have the knowledge of the following C programming topics:


As you know, the best way to concatenate two strings in C programming is by using the strcat() function. However, in this example, we will concatenate two strings manually.


Concatenate Two Strings Without Using strcat()

Output

After concatenation: programming is awesome

Here, two strings s1 and s2 and concatenated and the result is stored in s1.

It's important to note that the length of s1 should be sufficient to hold the string after concatenation. If not, you may get unexpected output.