strcpy, wcscpy, _mbscpy

문자열을 복사 합니다.보다 안전한 버전의이 함수를 사용할 수 있습니다. see _mbscpy_s, wcscpy_s strcpy_s.

중요중요

_mbscpy실행 하는 응용 프로그램에서 사용할 수 있는 Windows 런타임.자세한 내용은 /zw에 지원 되는 CRT 함수.

char *strcpy(
   char *strDestination,
   const char *strSource 
);
wchar_t *wcscpy(
   wchar_t *strDestination,
   const wchar_t *strSource 
);
unsigned char *_mbscpy(
   unsigned char *strDestination,
   const unsigned char *strSource 
);
template <size_t size>
char *strcpy(
   char (&strDestination)[size],
   const char *strSource 
); // C++ only
template <size_t size>
wchar_t *wcscpy(
   wchar_t (&strDestination)[size],
   const wchar_t *strSource 
); // C++ only
template <size_t size>
unsigned char *_mbscpy(
   unsigned char (&strDestination)[size],
   const unsigned char *strSource 
); // C++ only

매개 변수

  • strDestination
    대상 문자열입니다.

  • strSource
    소스를 null로 끝나는 문자열입니다.

반환 값

이러한 각 함수는 대상 문자열을 반환합니다.반환 값이 없는 오류를 나타내기 위해 예약 되어 있습니다.

설명

strcpy 복사 함수 strSource를 null 종결 문자에 의해 지정 된 위치를 포함 하 여 strDestination.동작을 strcpy 원본 및 대상 문자열 겹칠 경우 정의 되어 있지 않습니다.

보안 정보보안 정보

때문에 strcpy 충분 한 공간을 확인 하지 않습니다 strDestination 에 복사 하기 전에 strSource, 버퍼 오버런의 원인일 것입니다.따라서 사용 하는 것이 좋습니다 strcpy_s 대신 합니다.

wcscpy및 _mbscpy 각각의 와이드 문자 및 멀티 바이트 문자 버전입니다 strcpy.인수 및 반환 값을 wcscpy 와이드 문자 문자열입니다. _mbscpy 멀티 바이트 문자 문자열입니다.이러한 세 가지 함수 그렇지에 동일 하 게 동작 합니다.

C + +에서는 이러한 함수 최신, 보안 대응 함수를 호출 하는 템플릿 오버 로드 되어 있습니다.자세한 내용은 보안 템플릿 오버 로드을 참조하십시오.

일반 텍스트 루틴 매핑

TCHAR입니다.H 루틴

_UNICODE 및 _Mbcs가 정의 되어 있지 않습니다

_Mbcs가 정의

_Unicode가 정의

_tcscpy

strcpy

_mbscpy

wcscpy

요구 사항

루틴

필수 헤더

strcpy

<string.h>

wcscpy

<string.h> 또는 <wchar.h>

_mbscpy

<mbstring.h>

추가 호환성 정보를 참조 하십시오. 호환성.

예제

// crt_strcpy.c
// compile with: /W3
// This program uses strcpy
// and strcat to build a phrase.

#include <string.h>
#include <stdio.h>

int main( void )
{
   char string[80];

   // If you change the previous line to
   //   char string[20];
   // strcpy and strcat will happily overrun the string
   // buffer.  See the examples for strncpy and strncat
   // for safer string handling.

   strcpy( string, "Hello world from " ); // C4996
   // Note: strcpy is deprecated; use strcpy_s instead
   strcat( string, "strcpy " );           // C4996
   // Note: strcat is deprecated; use strcat_s instead
   strcat( string, "and " );              // C4996
   strcat( string, "strcat!" );           // C4996
   printf( "String = %s\n", string );
}
  

해당 .NET Framework 항목

System::String::Copy

참고 항목

참조

문자열 조작 (CRT)

strcat, wcscat, _mbscat

strcmp, wcscmp, _mbscmp

strncat, _strncat_l, wcsncat, wcsncat_l, _mbsncat _mbsncat_l

strncmp, wcsncmp, _mbsncmp, _mbsncmp_l

strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l

_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l

strrchr, wcsrchr, _mbsrchr, _mbsrchr_l

strspn, wcsspn, _mbsspn, _mbsspn_l