Category : C++ Source Code
Archive   : VCCRT1.ZIP
Filename : LFIND.C

 
Output of file : LFIND.C contained in archive : VCCRT1.ZIP
/***
*lfind.c - do a linear search
*
* Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
*
*Purpose:
* defines lfind() - do a linear search of an array.
*
*******************************************************************************/

#include
#include
#include


/***
*void *_lfind(key, base, num, width, compare) - do a linear search
*
*Purpose:
* Performs a linear search on the array, looking for the value key
* in an array of num elements of width bytes in size. Returns
* a pointer to the array value if found, NULL if not found.
*
*Entry:
* void *key - key to search for
* void *base - base of array to search
* unsigned *num - number of elements in array
* int width - number of bytes in each array element
* int (*compare)() - pointer to function that compares two array values,
* returning 0 if they are equal and non-0 if they are
* different. Two pointers to array elements are
* passed to this function.
*
*Exit:
* if key found:
* returns pointer to array element
* if key not found:
* returns NULL
*
*Exceptions:
*
*******************************************************************************/

void * _lfind (key, base, num, width, compare)
REG2 const void *key;
REG1 const void *base;
REG3 unsigned int *num;
unsigned int width;
int (*compare)(const void *, const void *);
{
unsigned int place = 0;

while ( place < *num )
if ( !(*compare)(key, base) )
return((void *) base);
else
{
base = (char *) base + width;
place++;
}

return(NULL);

}


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