什么是lfind

核心提示函数名: lfind功 能: 执行线性搜索用 法: void *lfind(void *key, void *base, int *nelem, int width,int (*fcmp)(const void *, const void

最佳答案:

函数名: lfind

详情介绍

函数名: lfind

功 能: 执行线性搜索

用 法: void *lfind(void *key, void *base, int *nelem, int width,

int (*fcmp)(const void *, const void *));

中文名
lfind
功 能
执行线性搜索
用 法
void *lfind(void *key,
程序例
#include

示例

#include <stdlib.h>

#include <stdio.h>

#include <search.h>

int compare(int *x, int *y)

{

return( *x - *y );

}

int main(void)

{

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

size_t nelem = 5;

int key;

int *result;

key = 99;

result = lfind(&key, array, &nelem,

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

if (result)

printf("Number %d foundn",key);

else

printf("Number %d not foundn",key);

return 0;

}

 
友情链接
鄂ICP备19019357号-22