XINU
memcmp.c
Go to the documentation of this file.
1 
6 /*------------------------------------------------------------------------
7  * memcmp - Compare two equal-size blocks of memory. If there are no
8  * differences, return 0. Otherwise return >0 or <0
9  * if the first differing byte is greater or less
10  *------------------------------------------------------------------------
11  */
19 int memcmp(const void *s1, const void *s2, int n)
20 {
21  const unsigned char *c1;
22  const unsigned char *c2;
23 
24  for (c1 = s1, c2 = s2; n > 0; n--, c1++, c2++)
25  {
26  if (*c1 != *c2)
27  {
28  return ((int)*c1) - ((int)*c2);
29  }
30  }
31  return 0;
32 }
int memcmp(const void *s1, const void *s2, int n)
Byteブロック2個に対して、先頭からN Byte分比較する。
Definition: memcmp.c:19