对memcpy函数的改进

  1. void *mymemcpy(void *dst,const void *src,size_t num)  
  2. {  
  3.     assert((dst!=NULL)&&(src!=NULL));  
  4.     int wordnum = num/4;//计算有多少个32位,按4字节拷贝  
  5.     int slice = num%4;//剩余的按字节拷贝  
  6.     int * pintsrc = (int *)src;  
  7.     int * pintdst = (int *)dst;  
  8.     while(wordnum--)*pintdst++ = *pintsrc++;  
  9.     while (slice--)*((char *)pintdst++) =*((char *)pintsrc++);  
  10.     return dst;  
  11. }  
原文地址:https://www.cnblogs.com/405845829qq/p/4381109.html