Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::strcat

      From cppreference.com
      <cpp‎ |string‎ |byte
       
       
       
       
      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

      [edit]Parameters

      dest - pointer to the null-terminated byte string to append to
      src - pointer to the null-terminated byte string to copy from

      [edit]Return value

      dest

      [edit]Notes

      Becausestrcat needs to seek to the end ofdest on each call, it is inefficient to concatenate many strings into one usingstrcat.

      [edit]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!

      [edit]See also

      concatenates a certain amount of characters of two strings
      (function)[edit]
      copies one string to another
      (function)[edit]
      C documentation forstrcat
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/string/byte/strcat&oldid=161092"

      [8]ページ先頭

      ©2009-2025 Movatter.jp