- cstring[meta header]
- std[meta namespace]
- function[meta id-type]
namespace std {
char* strcat(char* s1, const char* s2);
}文字列を結合する。
s2が指す文字列を、終端のヌル文字を含めてs1が指す文字列の末尾に連結する。s1の終端ヌル文字がs2の先頭文字で上書きされる。
コピー元とコピー先の領域が重なっている場合、動作は未定義である。
s1を返す。
- この関数は、フリースタンディング処理系でも使用できる。
s1が指す配列は、連結後の文字列を終端のヌル文字まで格納できる十分な大きさを持っていなければならない。
#include <cstring>
#include <iostream>
int main()
{
char s[12] = "hello";
std::strcat(s, " world");
std::cout << s << std::endl;
}- std::strcat[color ff0000]
hello world
- C++98
- P2338R4 Freestanding Library: Character primitives and the C library
- C++26で、この関数がフリースタンディング処理系で使用可能になった