C Standard Libraries C++

strcat()

Declaration

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

Description

This function appends the null-terminated string "kcpSrc" to the null-terminated string "cpDest" with result being stored in "cpDest." The function returns the pointer "cpDest."

Example

#include <cstdio>
#include <cstring>

int main()
{
    char caSource[] = ".net";
    // Allocate enough room for concatenation
    char caDest[10] = "XoaX";

    // The two strings before concatenation
    printf("%s + %s = ", caDest, caSource);
    strcat(caDest, caSource);

    // The destination string after concatenation
    printf(" %s\n", caDest);

    return 0;
}

Output

strcat() Output
 

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