1.函數(shù)原型:
LPTSTR
lstrcpyn(
LPTSTR
lpString1,
LPCTSTR
lpString2,//指向一個(gè)以NULL結(jié)束的字符串
int
iMaxLength //從lpString2拷貝到lpString1的字符串個(gè)數(shù),包括NULL字符
);
成功返回指向lpString1的指針,否則返回NULL。
如果lpString2的長(zhǎng)度大于iMaxLength,該方法實(shí)際上是
將lpString2中的前iMaxLength-1個(gè)字符和
一個(gè)NULL字符拷貝到lpString1中。
如果該方法成功,則lpString1一定是以NULL結(jié)束的字符串。
2._tcsncpy是一個(gè)宏,考慮在unicode的情況下
define _tcsncpy wcsncpy
wchar_t *
wcsncpy(
wchar_t *
strDest,
const wchar_t *
strSource,
size_t
count );
Parameters
- strDest
-
Destination string.
- strSource
-
Source string.
- count
-
Number of characters to be copied.
Return Value
Returns strDest. No return value is reserved to indicate an error.
不能保證NULL結(jié)束,將count個(gè)字符拷貝到strDest中。