XINU
Functions
memcmp.c File Reference

Byteブロック2個に対して、先頭からN Byte分比較する。 More...

Go to the source code of this file.

Functions

int memcmp (const void *s1, const void *s2, int n)
 Byteブロック2個に対して、先頭からN Byte分比較する。 More...
 

Detailed Description

Byteブロック2個に対して、先頭からN Byte分比較する。

Definition in file memcmp.c.

Function Documentation

◆ memcmp()

int memcmp ( const void *  s1,
const void *  s2,
int  n 
)

Byteブロック2個に対して、先頭からN Byte分比較する。

Parameters
[in]s1Byteブロックその1
[in]s2Byteブロックその2
[in]n比較するサイズ(Byte)
Returns
Byteブロックs1とs2に差がなければ0、s1>s2の場合は正の値、s1<s2の場合は負の値を返す。

Definition at line 19 of file memcmp.c.

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 }