Simon Shi的小站

人工智能,机器学习, 强化学习,大模型,自动驾驶

0%

C/C++ Doc

memccpy

1
2
3
4
5
6
void *memccpy(void * restrict dest, const void * restrict src, int c, size_t count);

dest - pointer to the object to copy to
src - pointer to the object to copy from
c - terminating character, converted to unsigned char at first
count - number of characters to copy

这里容易出现理解偏差的是参数 c,“terminating character, converted to unsigned char at first” 也就是参数会转化为unsigned char 也就是需要传入的是单个字符,当检测到传入的src 中字符与”c”匹配时,停止copy,退出.

参考资料:

https://en.cppreference.com/w/c/string/byte/memccpy