memcpy

void *memcpy(void *dest, const void *src, size_t n)  
/*源码并非单字节进行拷贝,会利用更高效的算法*/
void *memcpy(void *dest, const void *src, size_t count)
{
    char *d;
    const char *s;

    if (dest >= (src+count)) || (dest <= src)) {
        d = dest;
        s = src;
        while (count--) {
            *d++ = *s++;
       }
    } else {  /* overlap */
        d = (char *)(dest + count - 1); /* offset of pointer is from 0 */
        s = (char *)(src + count -1);
        while (count --) {
            *d-- = *s--;
        }
    }
    return dest;
}

本文固定链接: http://www.js-code.com/c/c_61793.html