【问题标题】:strncpy and _tcsncpy c++ examplestrncpy 和 _tcsncpy c++ 示例
【发布时间】:2013-10-02 12:12:57
【问题描述】:

我在谷歌找不到任何明确的来源,所以我决定在这里问。

c++ 中的函数 strncpy 和 _tcsncpy 接受 3 个参数:destination、source 和 nCount。

我不清楚第三个参数 nCount 是什么。是要复制的字符数还是缓冲区大小(以字节为单位)?

【问题讨论】:

  • count - maximum number of characters to copycopy/pasted from here。我真的只是用谷歌搜索了“strncpy”。
  • 谷歌搜索“strncpy 参考”一无所获?真的吗? this 怎么样?
  • 这很容易被谷歌回答。

标签: c++ string copy strncpy


【解决方案1】:

将源的前 num 个字符复制到目标。

来源:http://www.cplusplus.com/reference/cstring/strncpy/

您可以使用strlcpy 复制第一个num 字节。

【讨论】:

    猜你喜欢
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    相关资源
    最近更新 更多