c program to copy a string without using strcpy function

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

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

Output:

Enter the string :code2master.com Copied String is code2master.com

As you can see, we have copied one string to other without using strcpy() function.

Explanation

Explaination is fairly straight forward.

  • Iterate over string from left to rigth
  • Copy each character one by one
  • Once we get ‘/0’ in first string, while loop will terminate
  • Assign null character to the end of the copied String

Leave a Reply

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