_mbsnbcpy, _mbsnbcpy_l
Copy n bytes of a string to a destination string. These functions are deprecated because more secure versions are available; see _mbsnbcpy_s, _mbsnbcpy_s_l.
unsigned char * _mbsnbcpy( unsigned char * strDest, const unsigned char * strSource, size_t count ); unsigned char * _mbsnbcpy_l( unsigned char * strDest, const unsigned char * strSource, size_t count, _locale_t locale ); template <size_t size> unsigned char * _mbsnbcpy( unsigned char (&strDest)[size], const unsigned char * strSource, size_t count ); // C++ only template <size_t size> unsigned char * _mbsnbcpy_l( unsigned char (&strDest)[size], const unsigned char * strSource, size_t count, _locale_t locale ); // C++ only
Parameters
- strDest
-
Destination for character string to be copied.
- strSource
-
Character string to be copied.
- count
-
Number of bytes to be copied.
- locale
-
Locale to use.
The _mbsnbcpy function copies count bytes from strSource to strDest. If count is less than or equal to the size in bytes of strSource, a null character is not appended automatically to the copied string. If size in bytes of strSource is less than count, the destination buffer is padded with null characters. If count exceeds the size of strDest or the source and destination strings overlap, the behavior of _mbstrncpy is undefined.
If strSource or strDest is a null pointer, this function invokes the invalid parameter handler as described in Parameter Validation. If execution is allowed to continue, the function returns NULL and sets errno to EINVAL.
The output value is affected by the setting of the LC_CTYPE category setting of the locale; see setlocale for more information. The versions of these functions without the _l suffix use the current locale for this locale-dependent behavior; the versions with the _l suffix are identical except that they use the locale parameter passed in instead.
Security Note This API incurs a potential threat brought about by a buffer overrun problem. Buffer overrun problems are a frequent method of system attack, resulting in an unwarranted elevation of privilege. For more information, see Avoiding Buffer Overruns.
In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see Secure Template Overloads.
| Routine | Required header | Compatibility |
|---|---|---|
| _mbsnbcpy | <mbstring.h> | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 |
| _mbsnbcpy_l | <mbstring.h> | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 |
For more compatibility information, see Compatibility in the Introduction.
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.