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

 
Output of file : BLKCMP.C contained in archive : CSRC2.ZIP
/*
* b l k c m p . c
*/

/*)LIBRARY
*/

#ifdef DOCUMENTATION

title blkcmp Compare Two Blocks of Memory
index Compare two blocks of memory

synopsis

blkcmp(a,b,nbytes)
char *a;
char *b;
unsigned nbytes;

description

blkcmp compares two blocks of memory, each nbytes long. Like strcmp,
it returns:

-1 a < b
0 a == b
+1 a > b

where the comparison is lexicographical (as for strcmp).

Zero bytes have no special meaning to blkcmp() and are compared
along with everything else.

bugs

author

Jerry Leichter
#endif

/*
)EDITLEVEL=05
* Edit history
* 0.0 18-Jun-81 JSL Invention
* 0.1 23-Jun-81 JSL nbytes should be unsigned
*/

blkcmp(a,b,nbytes)
register char *a;
register char *b;
unsigned nbytes;
{ register int comp;

while (nbytes-- > 0)
{ if ((comp = *a++ - *b++) > 0)
return(1);
else if (comp < 0)
return(-1);
}
return(0);
}


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