Write an intelligent editor to simulate the following:
While typing if a new word starts with the same letters as that of some previously typed word, the choice of selecting the word instead of typing the whole should be given.
This is my homework.
My Algorithm :
1: Read the input by everytime checking the _kbhit() macro.
2: Store the word in an array
3: On every further read, check the array if the word exists.
Now the problem occurs!!!
How do I give the user an option to select the word or not???
And even if giving option is successful, how do I know wether user has decided to opt for that word?
I am new to this style of programming. Anyone knows how to do this, Please help me out…
It depend on how do you read the input, and communicate with the user. If it’s just a terminal, I suggest you to define one key (probably tab or esc) to move to
choosing state, and then let him (for example) hit a number (or keys).Edit: some code: