Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 1.4 KB

File metadata and controls

65 lines (44 loc) · 1.4 KB

strcat

  • 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

関連項目

  • strncat: 文字列を結合する(上限サイズ指定)
  • strcpy: 文字列をコピーする

参照