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
4 ★ | 1 Vote
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
Video: Close-up of the destructive power of a 12th-century catapult
The world's oldest and most famous gaming magazine has just closed
The world's widest boulevard with 16 lanes was completed half a century ago
Korea stirs because robot employee 'self-destructs'
Billionaire Musk's SpaceX took on the job of destroying the ISS
Nostradamus and prophecies about the world's destiny in 2021