kbhit.h

  • Katushai
  • Graduate
  • Graduate
  • Avatar de l’utilisateur
  • Inscription: Oct 11, 2003
  • Messages: 152
  • Status: Offline

Message Octobre 30th, 2004, 11:41 am

Est-ce que quelqu'un sait où je peux obtenir kbhit.h pour linux, avec getch () en elle?
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Octobre 30th, 2004, 11:41 am

  • Daemonguy
  • Moderator
  • Web Master
  • Avatar de l’utilisateur
  • Inscription: Jan 23, 2004
  • Messages: 2673
  • Loc: Somewhere outside the box in Sarasota, FL.
  • Status: Offline

Message Octobre 30th, 2004, 3:10 pm

Trouvé certains il ya quelque temps, il acheva.

Apprécier.
C'est vous qui voyez.

Code: [ Select ]
* kbhit.h */

#include

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;
}
  1. * kbhit.h */
  2. #include
  3. int kbhit(void)
  4. {
  5. struct timeval tv;
  6. fd_set read_fd;
  7. tv.tv_sec=0;
  8. tv.tv_usec=0;
  9. FD_ZERO(&read_fd);
  10. FD_SET(0,&read_fd);
  11. if(select(1, &read_fd, NULL, NULL, &tv) == -1)
  12. return 0;
  13. if(FD_ISSET(0,&read_fd))
  14. return 1;
  15. return 0;
  16. }


Inclure et les kbhit () thusly;

Code: [ Select ]
#include
#include "kbhit.h"

int main()
{
printf("hello\n");
printf("Press any key to continue..\n");
while(!kbhit());
printf("bye bye\n");

return 0;
}
  1. #include
  2. #include "kbhit.h"
  3. int main()
  4. {
  5. printf("hello\n");
  6. printf("Press any key to continue..\n");
  7. while(!kbhit());
  8. printf("bye bye\n");
  9. return 0;
  10. }


À la vôtre.
"It's always a long day, 86,400 won't fit into a short."

Afficher de l'information

  • Total des messages de ce sujet: 2 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 49 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC