Re: stdin help
- From: "Alastair" <adadachanji@xxxxxxxxx>
- Date: 4 Jan 2006 08:39:20 -0800
sajjanharudit@xxxxxxxxx wrote:
> i need to check the stdin, repeatedly for an input form the keyboard,
> with out prompting the user to press a key or without returning pressed
> key on screen..
>
> now the problem is that if i use getc() the program execution stpos at
> this line and waits for the user to press a key. cant use getchar
> because the key pressed appears on the screen and moreover it is
> buffered.
>
> what i need is a small technique whereby which I can check the stdin
> for an input, without prompting the user(the user will enter a key as
> and when he wishes, not depending on the program) AND without halting
> the execution (as getc() does) AND without displaying the key on the
> screen AND should store the pressed key to variable
This is not so straightforward as you think it shoud be. I have
recently developed a simple program in C++ (I know, different language)
to do the same thing. I had to use a seperate thread (or process).
One process would do all the waiting (fgetc(stdin) amd all that), the
other process can periodically check on the results with a simple
"if(is_there_message_waiting())" type decision.
However it is not the same in C. You may need to write a seprate
communication handling program that stores the resulting messages in a
file (or other storage) - essentially a second process. This was one of
my trains of thought before I decided to use C++ for that particular
problem.
Interrupts is another method, but it all boils down to the same thing.
well, at least I can't think of another way....
Alastair
.
- Follow-Ups:
- Re: stdin help
- From: Chuck F.
- Re: stdin help
- References:
- stdin help
- From: sajjanharudit@xxxxxxxxx
- stdin help
- Prev by Date: Re: illegal memory access with function pointers
- Next by Date: Re: c and webservices?
- Previous by thread: Re: stdin help
- Next by thread: Re: stdin help
- Index(es):
Relevant Pages
|