#include
#include
int valeurs[] = { 0 , 2 , 8, 4 , 7 , 10 };
int compare (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
int main ()
{
int *pos;
int element = 7; //Elément à cherché dans le tableau
pos = (int*) bsearch (&element, valeurs, 7, sizeof (int), compare);
if ( pos != NULL )
printf ("%d est dans le tableau", *pos);
else
printf ("%d n'est pas dans le tableau", element);
return 0;
}