Aktualizovat „du5/program.c“
This commit is contained in:
parent
68011771d5
commit
7c453c5d78
@ -1,12 +1,16 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
struct pollfd mypoll = { STDIN_FILENO, POLLIN|POLLPRI };
|
||||||
char name[50][50];
|
char name[50][50];
|
||||||
int score[50];
|
int score[50];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
//Getting input
|
//Getting input
|
||||||
while(1){
|
while(1){
|
||||||
|
if( poll(&mypoll, 1, 2000)){
|
||||||
scanf("%d %[^\n]", &score[pos], name[pos]);
|
scanf("%d %[^\n]", &score[pos], name[pos]);
|
||||||
scanf("%*c");
|
scanf("%*c");
|
||||||
pos++;
|
pos++;
|
||||||
@ -14,6 +18,10 @@ int main(){
|
|||||||
if(tmpCh == '\n') break;
|
if(tmpCh == '\n') break;
|
||||||
ungetc(tmpCh, stdin);
|
ungetc(tmpCh, stdin);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char newName[50][50];
|
char newName[50][50];
|
||||||
int newScore[50];
|
int newScore[50];
|
||||||
|
Loading…
Reference in New Issue
Block a user