Hello ever one,
i've aquestion about reading from console screeen i've a search engine project and i want when i start to enter the required word to search the console begins to display suggestions like google,my problem now how can i make the main sense the letter before pressing enter to display the suggestions before the user press enter to search.
my mean in a nother way:
in main when i identify for ex
string i;
cin>>i;
the variable i will set to the value after entering it from console screen and press enter i want to sense every letter before pressing enter to be able to display suggestions to the user.
thanks alot.
i mean that i want to know what's the letter pressed on the keyboard sothat i can trace the word that's written char by char and display the suggestions before he ends his writing.
ex
let us have a console window and the user wants to search acertain word let it book.
i want when the user starts to print the first letter i start to display suggestions by knowing what he typed on the keyborad like
bo
boswtol
bokra
box office
book
like what's done in google i can make that by knowing what's the key pressed on the keyboard.
i hope my question is clear.
Yes, it can be done in the console, but you will likely want to use something like the NCurses library to handle "windowing" (in the console) and unbuffered input.
As far as disabling input buffering is concerned, getch()/getche() declared in conio.h might do the job. However conio is old and it would be good not to depend on it. If this is a small program and you make it just for fun, using conio is not a problem. Else, I'll have to agree with the guys above. But for the suggestions part you definitely have to make some OS API calls.
Though, I want to ask, why is it so important that the suggestion info shows up while the user enters the word? You could just have the user enter part of the word, hit enter, and then show a list with words whose initial letters match the input.
What I mean is that if the user enters bo and hits enter the program would display a list like this:
bottom box book bool boot
And if he enters boo and hits enter the list would be limited to:
book bool boot
I recall having done something like this as part of the implementation of the searching function of a phone number database program I once wrote... It's not a bad idea. Don't reject it as an option.
EDIT: I guess when Disch discovers this topic he will suggest that you get rid of the console and move to a windows application :D Let's wait and see...
Can we use searching for this problem? I mean, when user press box the computer will search in database (or array) wich data have same word (in this example we have 3 word b,o,x)
if data have same 3 word,computer will display it. And Like r0shi said, you can use getch() in conio