C Standard Libraries C++

strcpy()

Declaration

char* strcpy(char* cpDest, const char* kcpSrc);

Description

This function copies the bytes from the null-terminated string "kcpSrc" to the destination "cpDest." The strings must not overlap.

Example

#include <cstdio>
#include <cstring>

int main()
{
    char caSource[] = "XoaX.net";
    char caDest[20];
    // Copy the string "XoaX.net"
    strcpy(caDest, caSource);
    printf("Copied: %s\n", caDest);

    return 0;
}

Output

strcpy() Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.