Re: stdin help




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

.



Relevant Pages

  • Re: stdin help
    ... > 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 ... Your platform may ...
    (comp.lang.c)
  • stdin help
    ... 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 ... now the problem is that if i use getcthe program execution stpos at ...
    (comp.lang.c)
  • Re: stdin help
    ... > 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 ...
    (comp.lang.c)
  • Re: stdin help
    ... > 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 ... > now the problem is that if i use getcthe program execution stpos at ... platforms provide non-blocking input handling functions that will allow ...
    (comp.lang.c)