From 7c453c5d7852871e6a4465ea19afd13726288eb5 Mon Sep 17 00:00:00 2001 From: Artem Horbunov Date: Tue, 7 Apr 2020 15:50:40 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu5/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/du5/program.c b/du5/program.c index 4fac4b6..4ddbb8c 100644 --- a/du5/program.c +++ b/du5/program.c @@ -1,18 +1,26 @@ #include #include +#include +#include int main(){ + struct pollfd mypoll = { STDIN_FILENO, POLLIN|POLLPRI }; char name[50][50]; int score[50]; int pos = 0; //Getting input while(1){ - scanf("%d %[^\n]", &score[pos], name[pos]); - scanf("%*c"); - pos++; - int tmpCh = getc(stdin); - if(tmpCh == '\n') break; - ungetc(tmpCh, stdin); + if( poll(&mypoll, 1, 2000)){ + scanf("%d %[^\n]", &score[pos], name[pos]); + scanf("%*c"); + pos++; + int tmpCh = getc(stdin); + if(tmpCh == '\n') break; + ungetc(tmpCh, stdin); + } + else{ + break; + } } char newName[50][50];