![]() |
The strcat() function in C++ is a predefined function in the <cstring> header file that is used to concatenate two strings, by appending a copy of the source string to the end of the destination string. This function works by adding all the characters till the null character of the source string at the position where the null character is present in the destination string. Due to this, strcat() can only be used on null-terminated strings (Old C-Style Strings). Syntax of strcat() in C++char *strcat(char *destination, const char *source); Parameters of strcat() in C++
Return Value of strcat() in C++The strcat() function returns a pointer to the destination string. ![]() String Concatenation in C++ Example to Use strcat() in C++Input: src = "GeeksforGeeks is an" dest = "Online Learning Platform" Output: GeeksforGeeks is an Online Learning Platform The below example illustrates how we can use strcat() function to concatenate or append two strings in C++.
Output GeeksforGeeks is an Online Learning Platform
There is also a function similar to strcat() which only appends the given number of characters from the source string to the destination string. It is strncat(). |
Reffered: https://www.geeksforgeeks.org
C++ |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 15 |