XINU
Functions
strcmp.c File Reference

二つの文字列を比較し、その結果を返す。 More...

Go to the source code of this file.

Functions

int strcmp (char *str1, char *str2)
 二つの文字列を比較し、その結果を返す。 More...
 

Detailed Description

二つの文字列を比較し、その結果を返す。

Definition in file strcmp.c.

Function Documentation

◆ strcmp()

int strcmp ( char *  str1,
char *  str2 
)

二つの文字列を比較し、その結果を返す。

Parameters
[in]str1比較対象の文字列その1
[in]str2比較対象の文字列その2
Returns
str1 > str2の場合は1、s1 = s2の場合は0、str1 < str2の場合は-1を返す。

Definition at line 12 of file strcmp.c.

Referenced by devisid(), devonid(), newdev(), and newtype().

15 {
16  while (*str1 == *str2)
17  {
18  if (*str1 == '\0')
19  {
20  return 0;
21  }
22  str1++;
23  str2++;
24  }
25  if (*str1 < *str2)
26  {
27  return -1;
28  }
29  else
30  {
31  return 1;
32  }
33 }
Here is the caller graph for this function: