strcat() - Manipulation Function

How to use strcat() in C++?


strcat() appends or concatenates a copy of the source string to destination string by overwritting the null character of the destination with the first character of the source . This concatenate manipulation function returns the destination part.


char * strcat ( char * destination, const char * source );

Example :

#include <stdio.h>
#include <cstring.h>
int main ()
char dest[80];
char sour[80];
strcpy (dest,"Bus");
strcpy (sour,"es are crowded");
strcat (dest,sour);
printf ("Result string using strcat is: %s ",dest);
return 0;

Result :

Result string using strcat is: Buses are crowded

In the above example, this manipulation function appends the source string "es are crowded" to destination string. The null character at the end of the destination "Bus" is overwritten by "e", the first character of of source. It concatenates or appends the source with the destination.

C++ Tutorial

Ask Questions

Ask Question