What is the difference between memcpy() and strncpy() given the latter can easily be a substitute for the former?

前端 未结 3 1370
慢半拍i
慢半拍i 2021-02-13 21:52

What is the significant difference between memcpy() and strncpy()? I ask this because we can easily alter strncpy() to copy any type of da

3条回答
  •  礼貌的吻别
    2021-02-13 22:29

    When memory block requires to be copied memcpy is useful and data in the for of string strncpy is meaningful because of the natural advantage of '\0' terminated string. Otherwise both perform same pattern of copy after execution.

提交回复
热议问题