//_66_查找函数
//_66_main.cpp
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
char *alpha = "abcdefghijklmnopqrstuvwxyz";
int comp(const void *ch,const void *s);
int main()
{
printf("Enter a character: ");
char ch=getchar();
ch = tolower(ch);//将变元ch转换成小写字符
char *p = (char *)bsearch(&ch,alpha,26,1,comp);
if(p)
printf("%c is in alphabet.\n",*p);
else
printf("is not in alphabet.\n");
system("pause");
return 0;
}
int comp(const void *ch,const void *s)
{
return *(char *)ch - *(char *)s;
}