Category : C Source Code
Archive   : ECSTR.ZIP
Filename : MEMCMP.C

Output of file : MEMCMP.C contained in archive : ECSTR.ZIP
/* File : memcmp.c
Author : Richard A. O'Keefe.
Updated: 25 May 1984
Defines: memcmp()

memcmp(lhs, rhs, len)
compares the two memory areas lhs[0..len-1] ?? rhs[0..len-1]. It
returns an integer less than, equal to, or greater than 0 according
as lhs[-] is lexicographically less than, equal to, or greater than
rhs[-]. Note that this is not at all the same as bcmp, which tells
you *where* the difference is but not what.

Note: suppose we have int x, y; then memcmp(&x, &y, sizeof x) need
not bear any relation to x-y. This is because byte order is machine
dependent, and also, some machines have integer representations that
are shorter than a machine word and two equal integers might have
different values in the spare bits. On a ones complement machine,
-0 == 0, but the bit patterns are different.

This could have a Vax assembly code version, but as the return value
is not the value left behind by the cmpc3 instruction I haven't

int memcmp(lhs, rhs, len)
register char *lhs, *rhs;
register int len;
while (--len >= 0)
if (*lhs++ != *rhs++) return lhs[-1]-rhs[-1];
return 0;

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