原型: int memcmp(void *buf1, void *buf2, unsigned int count);
用法:#include <string.h>
功能:比较内存区域buf1和buf2的前count个字节。
说明:
当buf1<buf2时,返回值<0
当buf1=buf2时,返回值=0
当buf1>buf2时,返回值>0
源码实现:
int memcmp(const void *buffer1,const void *buffer2,int count)
{
if (!count)
return(0);
while ( --count && *(char *)buffer1 == *(char *)buffer2)
{
buffer1 = (char *)buffer1 + 1;
buffer2 = (char *)buffer2 + 1;
}
return( *((unsigned char *)buffer1) - *((unsigned char *)buffer2) );
}
转:http://blog.sina.com.cn/s/blog_4af62c070100ppi1.html