Strcpy () function in C
Char * strcpy function (char * dest, const char * src) copies the string pointed to by src to dest.
Char * strcpy function (char * dest, const char * src) copies the string pointed to by src to dest.
Declare strcpy () in C
Here is the declaration for strcpy () in C:
char * strcpy ( char * dest , const char * src )
Parameters
dest - This is the pointer to the array containing the newly copied string.
src - String to be copied.
Returns the value
This function returns a pointer to the dest destination string.
For example
The following C program illustrates the usage of strcpy () in C:
#include #include int main () { char src [ 40 ]; char dest [ 100 ]; memset ( dest , '' , sizeof ( dest )); strcpy ( src , "Hoc C co ban va nang cao tai QTM !!!" ); strcpy ( dest , src ); printf ( "Sau khi thuc hien ham strcpy, chuoi dest co dang: n%sn" , dest ); return ( 0 ); } Compile and run the above C program to see the results.
According to Tutorialspoint
Previous lesson: strcoll () function in C
Next lesson: Function strncpy () in C
Discover more
learn C programming things to know about C programming parameters in C run the command in CShare by
Marvin Fry
Update 25 May 2019
You should read it
- Memmove function in C
- Function strxfrm () in C
- The strcoll () function in C
- The function strcmp () in C
- The function strncmp () in C
- The Quiet Details That Make a Sports Betting Platform Feel Reliable
- Instructions on creating toy set images with ChatGPT AI
- How are AI agents changing the journalism industry?
- The strncpy () function in C
- The strcspn () function in C
- The strerror () function in C