Aktualizovat „du5/program.c“

This commit is contained in:
Artem Horbunov 2020-04-07 15:50:40 +00:00
parent 68011771d5
commit 7c453c5d78

View File

@ -1,18 +1,26 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <poll.h>
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];