copy one string into another using the strcpy function

In this example, we take on string input and copy that string into another variable with help of strcpy() function.

Copy String using strcpy() Function In C Programming

strcpy() function is used copy string and it's a in-built function provided by c programming. We must include <string.h> heder file to use this function.

Example :

#include <stdio.h>
#include <string.h>

int main()
    char Str[100];
    char Dest[100];
    printf("\n Please Enter any String :  ");
    strcpy(Dest, Str);
    printf("Source string: %s \n", Str);
    printf("Destination string: %s \n", Dest);

    return 0;

Output :

Please Enter any String :  Hello World!
Source string: Hello World!
Destination string: Hello World!

Share your thoughts

Ask anything about this examples