Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

strcat - Concatenate strings

&pagelevel(4)&pagelevel

Definition   

#include <string.h>

char *strcat(char *s1, const char *s2);

strcat appends a copy of string s2 to the end of string s1 and returns a pointer to s1.

The null byte (\0) at the end of string s1 is overwritten by the first character of string s2.
strcat terminates the string with the null byte (\0).

Return val.

Pointer to the result string.

Notes

Strings terminated with the null byte (\0) are expected as arguments.

strcat does not check whether memory area s1 is large enough for the result!

The behavior is undefined if memory areas overlap.

Example

#include <string.h>
#include <stdio.h>
int main(void)
{
  char text1[BUFSIZ];
  char text2[BUFSIZ];
  printf("Example of strcat - please enter 2 text lines!\n");
  if(scanf("%s %s", text1, text2) == 2)
  printf("%s\n", strcat(text1, text2));
  return 0;
}

See also

strncat