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
Update 25 May 2019
You should read it
- Memset () function in C
- The strrchr () function in C
- Memmove function in C
- Function strxfrm () in C
- The strcoll () function in C
- The function strcmp () in C
- The function strncmp () in C
- The strstr () function in C
- The function strpbrk () in C
- The strtok () function in C
- Strcat function in C
- The strlen () function in C
Maybe you are interested
Revealing new findings about the size of the galaxy Admire incredibly detailed images of the Orion Nebula through the eyes of the James Webb telescope This star 'tears up' its companion to create a rare beautiful nebula Galaxy merger moment gives glimpse into Milky Way's future Science has discovered the fastest-flying star in the Milky Way, reaching 8% of the speed of light Discovered organic molecules that can make life in the center of the Milky Way