Localization library | |||||||||||||||||||||||||
Regular expressions library(C++11) | |||||||||||||||||||||||||
Formatting library(C++20) | |||||||||||||||||||||||||
Null-terminated sequence utilities | |||||||||||||||||||||||||
Byte strings | |||||||||||||||||||||||||
Multibyte strings | |||||||||||||||||||||||||
Wide strings | |||||||||||||||||||||||||
Primitive numeric conversions | |||||||||||||||||||||||||
| |||||||||||||||||||||||||
Text encoding identifications | |||||||||||||||||||||||||
|
Functions | ||||||||||||||||||||||||||||||||||||
Character classification | ||||||||||||||||||||||||||||||||||||
Character manipulation | ||||||||||||||||||||||||||||||||||||
Conversions to numeric formats | ||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||
String manipulation | ||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||
String examination | ||||||||||||||||||||||||||||||||||||
Character array functions | ||||||||||||||||||||||||||||||||||||
Miscellaneous | ||||||||||||||||||||||||||||||||||||
Defined in header <cstring> | ||
char* strcat(char* dest,constchar* src); | ||
Appends a copy of the character string pointed to bysrc to the end of the character string pointed to bydest. The charactersrc[0] replaces the null terminator at the end ofdest. The resulting byte string is null-terminated.
The behavior is undefined if the destination array is not large enough for the contents of bothsrc anddest and the terminating null character.
The behavior is undefined if the strings overlap.
Contents |
dest | - | pointer to the null-terminated byte string to append to |
src | - | pointer to the null-terminated byte string to copy from |
dest
Becausestrcat
needs to seek to the end ofdest on each call, it is inefficient to concatenate many strings into one usingstrcat
.
#include <cstdio>#include <cstring> int main(){char str[50]="Hello ";char str2[50]="World!"; std::strcat(str, str2); std::strcat(str," Goodbye World!");std::puts(str);}
Output:
Hello World! Goodbye World!
concatenates a certain amount of characters of two strings (function)[edit] | |
copies one string to another (function)[edit] | |
C documentation forstrcat |