Table of Contents

strcat

#include <stdlib.h>
char *strcat(char *str1, const char *str2);

description of strcat

The strcat function concatenates two strings.
str1 = target string to be added to source
str2 = source string to copied, including '\ 0' at the end of destination.
null byte of destination will be overwritten.

strcat C Sourcecode Example

/* 
 * strcat example code
 * http://code-reference.com/c/string.h/strcat
 */
#include <stdio.h>
#include <string.h>
 
int main ( void )
{
    char str[42]="strcpy ";
    strcat (str,"c example ");
    printf("%s\n", str);
    strcat(str, "for c");
    printf("%s\n", str);
return 0;
}

output of strcat c example

  user@host:~$ ./strcat 
  strcpy c example 
  strcpy c example for c