Question: C - Program I need help writting a function in C that is given a dictionary name, word to find, and length of each line
C - Program
I need help writting a function in C that is given a dictionary name, word to find, and length of each line in file. Only using read, write, and lseek see if the word to find is in the file.
int search(char *dictonaryName, char *word, int length).
Other requirements: dictionary format is 1 word per line and lines are in ascending sorted alphabetical order. Use binary search.
If the word is found return the line number of the word and if it is not present it should return the negative number of the last line searched.
What I have so far: discard int line_number and char buffer[512]

help please! Thanks in advanced.
int ok(char *dictionaryName, char *word, int length) { FILE *fd; int line_num = 1; char buffer[512]; // open the dictionary file int fd = fopen(dictionaryName, O_RDONLY, @); if( fd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
