DSP

内存赋值memcpy实现

2019-07-13 19:11发布

#include #include void *memcpy(void *memTo, const void *memFrom, size_t size) // typedef unsinged int size_t 其大小足以保证存储内存中对象的大小 { assert((memTo != NULL) && (memFrom != NULL)); char *tempFrom = (char*) memFrom; char *tempTo = (char*) memTo; while(size-- > 0) { *tempTo++ = *tempFrom++; } return memTo; } int main() { char strSrc[] = "hello World!"; char strDest[20]; memcpy(strDest,strSrc,4); strDest[4] = '