lstrcpyn,lstrcat, lstrcmp, lstrcmpi

28 篇文章 0 订阅
24 篇文章 0 订阅

The lstrcpyn function copies a specified number of characters from a source string into a buffer.

LPTSTR lstrcpyn(
  LPTSTR lpString1,  // destination buffer
  LPCTSTR lpString2, // string
  int iMaxLength     // number of characters to copy
);
Parameters
lpString1
[out] Pointer to a buffer into which the function copies characters. The buffer must be large enough to contain the number of TCHARs specified by iMaxLength, including room for a terminating null character.
lpString2
[in] Pointer to a null-terminated string from which the function copies characters.
iMaxLength
[in] Specifies the number of TCHARs to be copied from the string pointed to by lpString2 into the buffer pointed to by lpString1, including a terminating null character. This refers to bytes for ANSI versions of the function or WCHARs for Unicode versions.
Return Values

If the function succeeds, the return value is a pointer to the buffer. The function can succeed even if the source string is greater than iMaxLength characters.

If the function fails, the return value is NULL.

Remarks

Note that the buffer pointed to by lpString1 must be large enough to include a terminating null character, and the string length value specified by iMaxLength includes room for a terminating null character. Thus, the following code

TCHAR chBuffer[512] ;
lstrcpyn(chBuffer, "abcdefghijklmnop", 4) ;

copies the string "abc", followed by a terminating null character, to chBuffer.

The lstrcpyn function has an undefined behavior if source and destination buffers overlap.

Windows 95/98/Me: lstrcpynW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.

Requirements

  Windows NT/2000/XP: Included in Windows NT 3.5 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP. Also supported by Microsoft Layer for Unicode.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值