English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C Language Basic Tutorial

C Language Flow Control

C Language Functions

C Language Arrays

C Language Pointers

C Language Strings

C Language Structure

C Language File

C Others

C Language Reference Manual

Usage and example of C library function strcat()

C Standard Library - <string.h>

C Library Function char *strcat(char *dest, const char *src) Appending src The string pointed to is appended to dest The end of the string pointed to.

Declaration

Below is the declaration of the strcat() function.

char *strcat(char *dest, const char *src)

Parameters

  • dest -- Pointer to the destination array, which contains a C string and is large enough to hold the appended string.
  • src -- Pointer to the string to be appended, which will not overwrite the destination string.

Return Value

The function returns a pointer to the final destination string dest.

Online Example

The following example demonstrates the usage of the strcat() function.

#include <stdio.h>
#include <string.h>
int main ()
{
   char src[50], dest[50];
   strcpy(src,  "This is source");
   strcpy(dest, "This is destination");
   strcat(dest, src);
   printf("The ultimate destination string: |%s|", dest);
   return(0);
}

Let's compile and run the above program, which will produce the following result:

The ultimate destination string: |This is destinationThis is source|

C Standard Library - <string.h>