아래 주소의 목록에서 더 많은 부분을 찾을 수 있다
http://msdn.microsoft.com/en-us/library/kk6xf663(v=vs.100).aspx
strcpy, wcscpy, _mbscpy
Copy a string. More secure versions of these functions are available; see strcpy_s, wcscpy_s, _mbscpy_s.
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
The strcpy function copies strSource, including the terminating null character, to the location specified by strDestination. The behavior of strcpy is undefined if the source and destination strings overlap.
Security Note |
---|
Because strcpy does not check for sufficient space in strDestination before copying strSource, it is a potential cause of buffer overruns. Consider using strcpy_s instead. |
wcscpy and _mbscpy are wide-character and multibyte-character versions of strcpy. The arguments and return value ofwcscpy are wide-character strings; those of _mbscpy are multibyte-character strings. These three functions behave identically otherwise.
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see Secure Template Overloads.
TCHAR.H routine | _UNICODE & _MBCS not defined | _MBCS defined | _UNICODE defined |
---|---|---|---|
_tcscpy | strcpy | _mbscpy | wcscpy |
Routine | Required header |
---|---|
strcpy | <string.h> |
wcscpy | <string.h> or <wchar.h> |
_mbscpy | <mbstring.h> |
For additional compatibility information, see Compatibility in the Introduction.
// 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]; // Note that 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; consider using strcpy_s instead strcat( string, "strcpy " ); // C4996 // Note: strcat is deprecated; consider using strcat_s instead strcat( string, "and " ); // C4996 strcat( string, "strcat!" ); // C4996 printf( "String = %s\n", string ); }
String = Hello world from strcpy and strcat!
'프로그래밍(Programming) > c++, 11, 14 , 17, 20' 카테고리의 다른 글
placement new , 생성자를 원하는 시점에 호출하기 (0) | 2013.05.19 |
---|---|
POD(S) - Plain Old Data Structures (0) | 2013.05.19 |
c++라이브러리 및 컨테이너 레퍼런스 (0) | 2013.05.13 |
커스텀 메모리 할당자 (Are we out of memory?) (0) | 2013.05.11 |
sqrt를 사용하지 않는 방법이있다면 피하자 (0) | 2013.05.08 |