Just got an assignment recently and need help with two questions from it.
Write a function, arraysearch, that searches through a sorted array of C
strings for a specified string, using the following function definition:
int arraysearch(char** array, int arraySize, char* searchString);
The function should return the index of the matching element in the
array, or the value 0 if the search string cannot be found.
The parameters are as follows:
Parameter Description
array Sorted array of C strings
arraySize Number of elements in the array
searchString C string being searched
Assumptions/Constraints
The strings in the array are sorted in ASCII alphabetical order.
The array and each of the elements of the array between 0 and
arraySize-1 are valid pointers.
The array may potentially contain a large number of elements, and the
function should be optimized for speed.
The array will not contain any duplicate elements.
based on this fact, it would be better to return a value of "-1" because 0 could potentially be a matching element (i.e, searching for five, unsorted).