lfind

函式名: lfind 功 能: 執行線性搜尋 用 法: void *lfind(void *key, void *base, int *nelem, int width, int (*fcmp)(const void *, const void *));

示例

#include <stdlib.h>

#include <stdio.h>

#include <search.h>

int compare(int *x, int *y)

{

return( *x - *y );

}

int main(void)

{

int array[5] = {35, 87, 46, 99, 12};

size_t nelem = 5;

int key;

int *result;

key = 99;

result = lfind(&key, array, ≠lem,

sizeof(int), (int(*)(const void *,const void *))compare);

if (result)

printf("Number %d found\n",key);

else

printf("Number %d not found\n",key);

return 0;

}

相關詞條

相關搜尋

熱門詞條

聯絡我們