How to achieve strncpy() functionality with strncpy_s() function?

后端 未结 4 975
小蘑菇
小蘑菇 2021-01-05 08:32

There\'re certain cases when I really need strncpy() funcitonalty - for example I have a function in a predefined interface that is passed an address of the buf

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-05 09:12

    You want null-termination where actualLength < length, and no null-termination where actualLength == length, right?

    So use strncpy_s for the case where actualLength < length and memcpy_s where actualLength == length.

提交回复
热议问题