Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

eigenes kbhit unter unix

Empfohlene Antworten

Veröffentlicht

hallo, ich fand folgenden quellcode der die funktion _kbhit (von conio.h unter windows) ersetzen soll

#include <termios.h> 

#include <string.h> 


int kbhit(void) { 

        struct termios term, oterm; 

        int fd = 0; 

        int c = 0; 

        tcgetattr(fd, &oterm); 

        memcpy(&term, &oterm, sizeof(term)); 

        term.c_lflag = term.c_lflag & (!ICANON); 

        term.c_cc[VMIN] = 0; 

        term.c_cc[VTIME] = 1; 

        tcsetattr(fd, TCSANOW, &term); 

        c = getchar(); 

        tcsetattr(fd, TCSANOW, &oterm); 

        if (c != -1) 

        ungetc(c, stdin); 

        return ((c != -1) ? 1 : 0); 

}
wenn ich nun folgendes testprogramm schreibe
#include <string.h>

#include <unistd.h>

#include <stdio.h>

#include <termios.h>


int kbhit(void);


int main(void) {


  int x;

  for(x=0;x<10;x++)

  {

    if(kbhit()) {

      printf("ja\n");

    } else {

      printf("nein\n");

    }

    sleep(1);

  }


  return 0;


}


// Hier steht noch die Funktion kbhit()

und ich es laufen lassen bekomme ich lauter "nein"'s....das ist richtig.... wenn ich aber eine taste drücke bekomme ich ein ja....aber nach diesem ja bleibt es auf ja....kann mir jemand helfen und sagn warum es nicht wieder auf nein sprint?? hier die ausgabe:
/mein/pfad/>./kbhit

nein

nein

kja                          // Hier wurde ein "k" gedrückt

ja

ja

ja

ja

ja

ja

ja

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.