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

 
Output of file : STRNEQ.C contained in archive : CSRC2.ZIP
/*
* s t r n e q . c
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

title strneq String Equality Test With Count
index String equality test with count

synopsis
.s.nf
int
strneq(s1, s2, count);
char *s1;
char *s2;
unsigned int count;
.s.f
Description

Compare at most count bytes between two strings, returning TRUE
if the the strings are equal.

Bugs

#endif

#define EOS 0
#define FALSE 0
#define TRUE 1

int
strneq(s1, s2, count)
register char *s1;
register char *s2;
register unsigned int count;
/*
* Return TRUE if equal up to count bytes.
*/
{
if (count == 0)
return (TRUE);
else {
while (*s1++ == *s2) {
if (*s2++ == EOS || --count == 0)
return (TRUE);
}
return (FALSE);
}
}


  3 Responses to “Category : C Source Code
Archive   : CSRC2.ZIP
Filename : STRNEQ.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/