GetDlgItemText API函数取得的字符最后一位是空字节?

老刘爱捣鼓 2011-12-09 11:29:39
为什么GetDlgItemText API函数取得的字符最后一位是空字节,这样定义定义变量长度的时候就必须比实际输入的字符长度要多一位是不是。
...全文
62 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
PointertoPointer 2011-12-09
  • 打赏
  • 举报
回复
兄弟,这里是汇编。
不过我觉得你说的很正确。个人意见,请参考^_^
cnfixit 2011-12-09
  • 打赏
  • 举报
回复
lpString
[out] Pointer to the buffer to receive the title or text.
nMaxCount
[in] Specifies the maximum length, in TCHARs, of the string to be copied to the buffer pointed to by lpString. If the length of the string, including the NULL character, exceeds the limit, the string is truncated.



If the string is as long or longer than the buffer, the buffer will contain the truncated string with a terminating NULL character.


c风格的字符串是以'\0'结尾的,所以假如字符串长度是10字节,实际上是11字节,最后有个'\0'

21,458

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧