From the course: C Standard Library

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Sort and search main

Sort and search main - C Tutorial

From the course: C Standard Library

Start my 1-month free trial

Sort and search main

- [Instructor] Here's an example application where I will run b search twice in an array that's the array defined in 9.14 which is called nums and it's an array of ten integers. As you can see it's not sorted in any particular way and I will look for one number that I know is in the array first and then I'll look for a number I know is not in the array. Now remember that b search requires the array to already be sorted and so I will have to call q sort so this application will show both functions. As you can see I have already written some code so I want you to pay attention to line four where I have a function that prints out the array. It's called print array and you may want to take a minute to verify what it does but it's just printing out integers. We also have a series of comments in the code that act as a to do list to fill in the blanks. So as you can see in lines ten and eleven we have to write a compare function and a find function. The compare function is the call back…

Contents