strncpy or strlcpy in my case

前端 未结 6 1281
执笔经年
执笔经年 2020-12-10 11:21

what should I use when I want to copy src_str to dst_arr and why?

char dst_arr[10];
char *src_str = \"hello\";

P

6条回答
  •  -上瘾入骨i
    2020-12-10 11:51

    strlcpy() is safer than strncpy() so you might as well use it.
    Systems that don't have it will often have a s_strncpy() that does the same thing.

    Note : you can't copy anything to dst_ptr until it points to something

提交回复
热议问题