std::strcat(3)
okay so welcome to std::strcat(3) from the C++ Standard Libary β yes, that's the header's spelling, not mine π β this is the group chat for the string-appending icon itself π
π NAME π
std::strcat β std::strcat (the main character, literally)
πΈ Synopsis πΈ
Defined in header <cstring>
char* strcat( char* dest, const char* src );
Appends a copy of the character string pointed to by src to the end of the character string pointed to by dest. The character src[0] replaces the null terminator at the end of dest. The resulting byte string is null-terminated. β¨
π¨ undefined behavior alert: the behavior is undefined if the destination array is not large enough for the contents of bothsrcanddestand the terminating null character. Also undefined if the strings overlap. no cap, do not do this π
π¦ Parameters π¦
destβ pointer to the null-terminated byte string to append tosrcβ pointer to the null-terminated byte string to copy from
π Return value π
dest β that's it, that's the return value, bestie π
β Notes β
Because strcat needs to seek to the end of dest on each call, it is inefficient to concatenate many strings into one using strcat. like, it's giving "works but not the vibe for a huge pile of strings" π
π Example π
// Run this code
#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!
π See also π
strncatβ concatenates a certain amount of characters of two strings (function)strcpyβ copies one string to another (function)- C documentation for
strcat
π okay that's the whole page, bestie! source/version shoutout: http://cppreference.com, dated 2024.06.10, for std::strcat(3) β bye, slay, periodt β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms