C Program to Concat two Strings without Using strcat Function

In this tutorial, we will see how to concat one string to other without using library function strcat.

Here is simple program to concat one string to other without using library function.

Output:

Enter String 1 :code Enter String 2 :2master
Concated string is :code2master

Explanation

Explaination is fairly straight forward.

  • Find the length of first String str1
  • Iterate over second string str2 and assign character to first String str1 starting from its length
  • Once we get ‘/0’ in second string str2, for loop will terminate
  • Assign null character to the end of the first String str1

Leave a Reply

Your email address will not be published. Required fields are marked *