home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
unix
/
unixlib36d
/
src
/
c
/
strcmp
< prev
next >
Wrap
Text File
|
1994-03-08
|
944b
|
53 lines
#ifdef __STDC__
static char sccs_id[] = "@(#) strcmp.c 1.1 " __DATE__ " HJR";
#else
static char sccs_id[] = "@(#) strcmp.c 1.1 26/9/90 HJR";
#endif
/* strcmp.c (c) Copyright 1990 H.Rogers */
#ifndef __STDC__
#include "sys/types.h"
#endif
#include <string.h>
#ifdef __STDC__
int
strcmp (register const char *s1, register const char *s2)
#else
int
strcmp (s1, s2)
register const char *s1;
register const char *s2;
#endif
{
register int i;
while ((i = *s1) && i == *s2)
s1++, s2++;
return (*(unsigned char *) s1 - *(unsigned char *) s2);
}
#ifdef __STDC__
int
strncmp (register const char *s1, register const char *s2, register size_t n)
#else
int
strncmp (s1, s2, n)
register const char *s1;
register const char *s2;
register size_t n;
#endif
{
register int i;
if (!n)
return 0;
while ((i = *s1) && i == *s2 && --n)
s1++, s2++;
return (*(unsigned char *) s1 - *(unsigned char *) s2);
}