一、memcpy和memove
void* memove(void*destin , void* source, size_t count) { //进行这样的判断是为了解决拷贝重叠的情况 if (destin > source) { //这里拷贝的时候还可以提高效率 //因为CPU单次可以拷贝的最大字节是8个 //所以完全可以用long* 替代 char*(前提是count>8) char* a = (char*)destin; char* b = (char*)source; while (count--) { *b++ = *a++; } } else { char* a = (char*)destin + count; char* b = (char*)source + count; while (count--) { *b-- = *a--; } } return destin; }
参考博客https://www.cnblogs.com/Bob-tong/p/6610806.html
C 库函数 char *strchr(const char *str, int c) 在参数 str 所指向的字符串中搜索第一次出现字符 c(一个无符号字符)的位置。
下面是 strchr() 函数的声明。
char *strchr(const char *str, int c)
该函数返回在字符串 str 中第一次出现字符 c 的位置,如果未找到该字符则返回 NULL。
C++ 相关的string 函数(memcpy、memove、strtok、strchr)
原文:https://www.cnblogs.com/-citywall123/p/13423075.html