Is strncpy() a specialization of memcpy()?

后端 未结 5 1617
伪装坚强ぢ
伪装坚强ぢ 2021-01-25 01:59

Just curious to know (as we use these functions often). I don\'t see any practical difference between strncpy() and memcpy(). Isn\'t it worth to say that effectively,

         


        
5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-25 02:14

    You could potentially make strncpy faster by checking for a \0 and not copying past that point. So memcpy would always copy all the data, but strncpy would often be faster because of the check.

提交回复
热议问题