| | |
non blocking getchar.. big problem :(
![]() |
•
•
Join Date: Apr 2007
Posts: 4
Reputation:
Solved Threads: 0
hi,
does anyone knows if is there a way to make getchar non blocking?
I'm using curses and I'm on linux platform. With a thread version of the same program I have solved my problems with getch and with the timeout function but now the program doesn't work properly and I must use
Using timeout(1) makes non blocking only the c=getch part of this code but not the getchar one.
I have tried to solve this problem using this function
and this code
but the program doesn't work properly...
Does anyone knows a solution?
I'm 5 days in a row searching of solve this big problem unhappy
does anyone knows if is there a way to make getchar non blocking?
I'm using curses and I'm on linux platform. With a thread version of the same program I have solved my problems with getch and with the timeout function but now the program doesn't work properly and I must use
C Syntax (Toggle Plain Text)
c=getchar(); if (c==0) c=getch();
I have tried to solve this problem using this function
C Syntax (Toggle Plain Text)
int kbhit(void) { struct timeval tv; fd_set read_fd; tv.tv_sec=0; tv.tv_usec=0; FD_ZERO(&read_fd); FD_SET(0,&read_fd); if(select(1, &read_fd, NULL, NULL, &tv) == -1) return 0; if(FD_ISSET(0,&read_fd)) return 1; return 0; }
and this code
C Syntax (Toggle Plain Text)
if (kbhit()) c = getchar();
Does anyone knows a solution?
I'm 5 days in a row searching of solve this big problem unhappy
![]() |
Similar Threads
- Big Problem (Viruses, Spyware and other Nasties)
- BIG problem... laptop screen shaking/whiting out! (Monitors, Displays and Video Cards)
- Big Problem!!!!!!!!!!! (Viruses, Spyware and other Nasties)
- Big Problem, Generic Error (VB.NET)
Other Threads in the C Forum
- Previous Thread: Help Please
- Next Thread: How to overload + operator for STL Vectors
| Thread Tools | Search this Thread |
* adobe ansi api array arrays binarysearch calculate centimeter char cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking hardware highest homework i/o inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix microsoft motherboard mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pattern pdf performance pointer posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h






