C/C++ Doc
memccpy123456void *memccpy(void * restrict dest, const void * restrict src, int c, size_t count);dest - pointer to the object to copy tosrc - pointer to the object to copy fromc - terminating character, converted to unsigned char at firstcount - 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/mem
...