Category : C Source Code
Archive   : CSRC2.ZIP
Filename : STRCMP.C

 
Output of file : STRCMP.C contained in archive : CSRC2.ZIP
/*
* s t r c m p . c
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

title strcmp String Compare
index String compare

synopsis
.s.nf
int
strcmp(s1, s2);
char *s1;
char *s2;
.s.f
Description

Compare two strings, returning

-1 if s1 < s2
0 if s1 == s2
+1 if s1 > s2

Bugs

#endif

#define EOS 0

int
strcmp(s1, s2)
register char *s1;
register char *s2;
/*
* Compare two strings.
*/
{
while (*s1++ == *s2) {
if (*s2++ == EOS)
return (0);
}
return ((s1[-1] < *s2) ? -1 : 1);
}


  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : STRCMP.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/