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