string book[] = {
"Chen",
"Kernighan",
"Leitner",
"Lewis",
"Malan",
"Muller",
"Seltzer",
"Shieber",
"Smith"
}
int main(void)
{
// Prompt user for name
string name = get_string("Name: ");
// Search for name
if (search(name, book, 0, sizeof(book) / sizeof(string) - 1))
{
printf("Calling %s\n", name);
}
else
{
printf("Quitting\n");
}
}
After completing problem set 3, I decided that it wouldn't be too bad of an idea to take a look at the implementations of sorts in the source code of the lecture. While looking at the binary sort, I saw that the right bound of the search was defined as above as sizeof(book) / sizeof(string) - 1. I dedcided to put each as a variable and ran them through debug50 to see their value. It showed that the size of the string was 8, where as the size of the book is 72. How were these values calculated, and furthermore how is it able to describe the right bound of the search?