user interrupt to enter a data and contitue the program in C 
Author Message
 user interrupt to enter a data and contitue the program in C

hi ,
      we are working on a program ,with a continuous loop and would like to
poll the input device (keyboard/mouse) ,if there is no input continue
looping.

how to do this in C ?

much appreciated.

thanks
arun

--
Posted via CNET Help.com
http://www.*-*-*.com/



Sat, 02 Nov 2002 03:00:00 GMT  
 user interrupt to enter a data and contitue the program in C

Quote:
> hi ,
>       we are working on a program ,with a continuous loop and would like
to
> poll the input device (keyboard/mouse) ,if there is no input continue
> looping.

> how to do this in C ?

You will need to be much more specific about your requirements. For example,
in C you could do this:

#include <stdio.h>

int main(void)
{
  int ch;

  while ( (ch = getchar() != '\n' )
    printf("%c", ch);

  return 0;

Quote:
}

However, I am guessing that this is not what you require.

The techniques and functions required to perform polling of devices such as
a keyboard or mouse are compiler and system-specific; they are not things
that the C language directly understands. It is probably best if you direct
your query to the relevant newsgroups.

You could try:






I hope this helps.



Sat, 02 Nov 2002 03:00:00 GMT  
 user interrupt to enter a data and contitue the program in C

Quote:

>hi ,
>      we are working on a program ,with a continuous loop and would like to
>poll the input device (keyboard/mouse) ,if there is no input continue
>looping.

>how to do this in C ?

You can't do this in C, but the FAQ mentions some possibilities for how
you may be able to do it on your system:

19.2:   How can I find out if there are characters available for reading
        (and if so, how many)?  Alternatively, how can I do a read that
        will not block if there are no characters available?

A:      These, too, are entirely operating-system-specific.  Some
        versions of curses have a nodelay() function.  Depending on your
        system, you may also be able to use "nonblocking I/O", or a
        system call named "select" or "poll", or the FIONREAD ioctl, or
        c_cc[VTIME], or kbhit(), or rdchk(), or the O_NDELAY option to
        open() or fcntl().  See also question 19.1.

--
Dave Vandervies

All my friends and I are crazy.  That's the only thing that keeps us sane.



Sat, 02 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help: getting user-entered data on close of ShowDialog()

2. trying to do a nslookup by asking the user to enter to enter multiple ip addresses

3. Newbie: separate big .cs file into small .cs files

4. How to avoid user from entering a new row into the datagrid[which already contains rows]

5. Problem #30 on http://cs.nmu.edu/programming/c/problems.htm

6. Having user re-enter input?

7. error checking in scanf: expecting int but user enter char

8. SoftEng or CS Graduate Program Search

9. FS: Programming and CS Books --- CHEAP

10. 1995 UT IEEE CS National Programming Contest

11. user defined software interrupt

12. Good CS Programs

 

 
Powered by phpBB® Forum Software