Previous: 9.8 Exercises
Up: 9.1 Two Dimensional Arrays
Previous Page: 9.8 Exercises
The dictionary should be kept sorted at all times and searched using binary search. Use an array of pointers to sort when new entries are inserted. In the spell check option, the program reads in lines of text from a file. Each word in a line is checked with the dictionary. If the word is present in the dictionary, it is ignored. Otherwise, the user is asked to make a decision: replace the word or add it to the dictionary. Either replace the word with a new word in the line or add the word to dictionary. Each corrected line is appended to a text buffer. At the quit command, the user is alerted if the text buffer has not been saved.
The function scan() returns a token in a string, type of the token, and index where the token is stored in the array. If the array is filled, a message saying so must be displayed.
Write a program driver to read strings repeatedly. For each string, call scan() to get a token. As scan() returns, print the token, its type, and index. Repeat until an end of string token is reached. When the end of file is encountered, print each of the tokens, its type, and index.
a00 x0 + a01 x1 + a02 x2 = b1