-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSTRNCMP.C
33 lines (31 loc) · 896 Bytes
/
STRNCMP.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*********************************************************************
* STRNCMP - compares strings up to n chars
*
* WORD strncmp(s1,s2,n)
* BYTE *s1, *s2;
* UWORD n;
*
* 'strncmp' compares null terminated strings s1 and s2, and examines
* at most n chars.
* Always compares at least 1 char.
* n < 0 compares many, many characters.
* Returns:
* strncmp < 0 if s1<s2 (within n chars)
* strncmp = 0 if s1=s2 " " "
* strncmp > 0 if s1>s2 " " "
*********************************************************************/
#include <portab.h>
WORD strncmp(s1,s2,num) /* CLEAR FUNCTION ***********/
REG BYTE *s1, *s2;
REG WORD num;
{
for( ; --num > 0 && (*s1 == *s2); s1++, s2++ )
if( *s1 == NULL )
return(0);
return(*s1 - *s2);
}
WORD num;
{
for( ; --num > 0 && (*s1 == *s2); s1++, s2++ )
if( *s1 == NULL )
return(0