Latest web development tutorials

C library functions - strcat ()

C standard library - <string.h> C standard library - <string.h>

description

C library functionschar * strcat (char * dest, const char * src) pointed to the srcstring appended to the end of the stringdestpoints.

statement

Here is () statement strcat function.

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

parameter

  • dest - to the target array, which contains a C string, and the string after the addition of sufficient to accommodate.
  • src - pointing to append the string does not overwrite the target string.

return value

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

Examples

The following example demonstrates the strcat () function is used.

#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("最终的目标字符串: |%s|", dest);
   
   return(0);
}

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

最终的目标字符串: |This is destinationThis is source|

C standard library - <string.h> C standard library - <string.h>