/** * ibs-expt.c * A quick experiment with integer binary search. */ // +---------+------------------------------------------------------- // | Headers | // +---------+ #include "bs.h" #include // +------+---------------------------------------------------------- // | Main | // +------+ int main (int argc, char *argv[]) { int v; int a[argc-2]; // Grab the value. (No error checking.) v = atoi(argv[1]); // Grab the array. (No error checking.) for (int i = 2; i < argc; i++) { a[i-2] = atoi(argv[i]); } // for i // Do the search int pos = binary_search_ints (v, a, argc-2); if (pos == -1) { printf ("The value could not be found.\n"); return 1; } // if (result == -1) else { printf ("%d appears at position %d\n", v, pos); } // if (result != -1) return 0; } // main(int, char**)