In this tutorial i will explain you strcpy() function in c programming. strcpy() function in c, copy one string into another string. In C strcpy c is available in string.h header file.
Why do u need strcpy() function ?
We can’t assign one string into another string using assignment operator that is why we need strcpy() function. Let’s take an example -
We have created two variable a and b, variable a contains value 10 but variable b is empty. We can assign variable a value to variable b using assignment operator.
In case of string i want to do similar kind of operation then it is not allowed in C using assignment operator and below given example is wrong.
destination : Pointer to the destination array where the content is to be copied.
source : This is string which will be copied. It might be string variable or string constant.
Example Program -