ReactOS
0.4.16-dev-1946-g52006dd
strcmp.c
Go to the documentation of this file.
1
/***
2
*strcmp.c - routine to compare two strings (for equal, less, or greater)
3
*
4
* Copyright (c) Microsoft Corporation. All rights reserved.
5
*
6
*Purpose:
7
* Compares two string, determining their ordinal order.
8
*
9
*******************************************************************************/
10
11
#include <string.h>
12
13
#pragma function(strcmp)
14
15
/***
16
*strcmp - compare two strings, returning less than, equal to, or greater than
17
*
18
*Purpose:
19
* STRCMP compares two strings and returns an integer
20
* to indicate whether the first is less than the second, the two are
21
* equal, or whether the first is greater than the second.
22
*
23
* Comparison is done byte by byte on an UNSIGNED basis, which is to
24
* say that Null (0) is less than any other character (1-255).
25
*
26
*Entry:
27
* const char * src - string for left-hand side of comparison
28
* const char * dst - string for right-hand side of comparison
29
*
30
*Exit:
31
* returns -1 if src < dst
32
* returns 0 if src == dst
33
* returns +1 if src > dst
34
*
35
*Exceptions:
36
*
37
*******************************************************************************/
38
39
int
__cdecl
strcmp
(
40
const
char
*
src
,
41
const
char
*
dst
42
)
43
{
44
int
ret
= 0 ;
45
46
while
((
ret
= *(
unsigned
char
*)
src
- *(
unsigned
char
*)
dst
) == 0 && *
dst
)
47
{
48
++
src
, ++
dst
;
49
}
50
51
return
((-
ret
) < 0) - (
ret
< 0);
// (if positive) - (if negative) generates branchless code
52
}
__cdecl
#define __cdecl
Definition:
accygwin.h:79
ret
return ret
Definition:
mutex.c:146
src
GLenum src
Definition:
glext.h:6340
dst
GLenum GLenum dst
Definition:
glext.h:6340
strcmp
int __cdecl strcmp(const char *src, const char *dst)
Definition:
strcmp.c:39
sdk
lib
ucrt
string
strcmp.c
Generated on Thu Dec 4 2025 06:16:23 for ReactOS by
1.9.6