* main.c
*
* Created on: Oct 29, 2010
* Author: jenson
*/
#include <stdio.h>
#include <stdlib.h>
int cmp(const void *ch,const void *s);
int main(){
char ch;
char *p;
printf("Enter a character:");
ch = getchar();
ch = tolower(ch);
p = (char *)bsearch(&ch,"abcdefghijklmnopqrstuvwxyz",26,1,cmp);
if(p){
printf("%c is found\n",ch);
}else{
printf("%c is not found.\n",ch);
}
return 0;
}
int cmp(const void *ch,const void *s){
return *(char *)ch - *(char *)s;
}