1.函數原型:
LPTSTR
lstrcpyn(
LPTSTR
lpString1,
LPCTSTR
lpString2,//指向一個以NULL結束的字符串
int
iMaxLength //從lpString2拷貝到lpString1的字符串個數,包括NULL字符
);
成功返回指向lpString1的指針,否則返回NULL。
如果lpString2的長度大于iMaxLength,該方法實際上是
將lpString2中的前iMaxLength-1個字符和
一個NULL字符拷貝到lpString1中。
如果該方法成功,則lpString1一定是以NULL結束的字符串。
2._tcsncpy是一個宏,考慮在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結束,將count個字符拷貝到strDest中。