Click to See Complete Forum and Search --> : how to detect string w/out hitting return?


alex
02-14-2001, 01:05 PM
i am not a cs major but an ee who needs help w/ a simple programming assignment.
the problem requires one to enter string inputs using the keyboard. when
a flag sequence is detected a prompt is displayed. all this is done w/out
hitting return for each character entered. my question is how can this be
done? i'm used to writing programs where inputs are entered and then the
return key is used to process the input. how can one type inputs and at
the same time have the computer read the inputs to detect the flag, all w/out
hitting enter?
thanks

Danny Kalev
02-14-2001, 01:25 PM
use the getche or _getche functions in <conio.h>. These are not standard
functions but Win32 and DOS support them and I assume you're not using
another platform. Read a single character from the keyborad in a loop
and leave the loop when the flag has been detected.

Danny

alex wrote:
>
> i am not a cs major but an ee who needs help w/ a simple programming assignment.
> the problem requires one to enter string inputs using the keyboard. when
> a flag sequence is detected a prompt is displayed. all this is done w/out
> hitting return for each character entered. my question is how can this be
> done? i'm used to writing programs where inputs are entered and then the
> return key is used to process the input. how can one type inputs and at
> the same time have the computer read the inputs to detect the flag, all w/out
> hitting enter?
> thanks

Tabrizi
02-14-2001, 06:53 PM
USE CHARACTER, USE CHARACTER.

alex
02-14-2001, 11:42 PM
"Tabrizi" <tabr@email.com> wrote:
>
>USE CHARACTER, USE CHARACTER.

i could've sworn i heard this from a professor i asked advice from on this
specific problem. is it coincidental that a professor at my school also
has the same name as this person or is this really him?..hehe
anyhow..thanks danny. i'm gonna look more into this getche function