Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

UNIX equiv of 'kbhit()' ??

Posted on 1998-03-11
6
Medium Priority
?
2,256 Views
Last Modified: 2012-08-13
I am working with SCO Unix using gcc for my compiler. I need to know the equiv of 'kbhit()'?  thanks.
0
Comment
Question by:kellyjj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 100 total points
ID: 1257664
There's no equivalent to kbhit() on Unix.

To handle keybord (and cursor position, and mouse, and windows, and so on) Unix has the "curses" library:

try man curses.

HTH.
0
 
LVL 2

Author Comment

by:kellyjj
ID: 1257665
Do you know where I can get some source code that could show me how to do this my self? or documentation on curses lib?  I don't have the man pages.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1257666
Hmmm... i'm afraid i don't; i've never needed curses myself, so don't know where you could get material from.

Just a few thoughts:

1. among the GNU stuff there is all to support C programming, so i guess they have man pages, too;

2. a net search for "man curses", or "man pages", or such, may also be of great help; there *is* stuff online (somewhere).

3. reject my answer, increase the points a bit (say 50), and wait for a better answer than mine; if nobody else comes in (not probable) you could anyway let me resubmit my answer, later.

Good luck.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 2

Author Comment

by:kellyjj
ID: 1257667
Here you go. You at least told me that there is no equiv.  And which lib deals with it.   Thanks
0
 

Expert Comment

by:macdonaldal
ID: 1257668
Kellyjj - I don't know if you have solved this problem - but I have just had to deal with it.
The solution I came up with is this - use the curses.h  lib and then use the function nodelay( stdwin, TRUE)
no you need to reset this at the end of your function and curse needs to be initialised first - If you want a good basic book on curses I suggest - "Programming with curses" by John Strang.
Alex
0
 

Expert Comment

by:BichiX
ID: 1257669
Para lograrlo tienes que probar con las propiedades de la terminal...
Por default la terminal esta en modo caconico asi que la opcion es colocarla del otro modo !!!
Con esto lo lograras !!! y sin hacer uso de la libreria "ncurses.h" !!!

#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <sys/time.h>

int main(){
        struct termios  tio0, tio1;
        struct timeval  tv;
        fd_set          rfds;

        /* Modo de Edicion Canonica ki */
        tcgetattr(0,&tio0);
        memcpy(&tio1,&tio0,sizeof(struct termios));
        tio1.c_lflag &= ~ICANON;
        tcsetattr(0,TCSANOW,&tio1);

        /* Es un kbhit() */
        FD_ZERO(&rfds);
        FD_SET(0,&rfds);
        tv.tv_usec      = 0;
        tv.tv_sec       = 1;
        select(1,&rfds,NULL,NULL,&tv);
        printf("%d\n",FD_ISSET(0,&rfds) ? 1:0);

        /* Modo de edicion Canonica vissza */
        tcsetattr(0,TCSANOW,&tio0);

        return( 0 );
}

Recuerda Desactivar este modo y dejarlo como estaba antes!!!
BichiX...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question