Aktualizovat „du5/program.c“
This commit is contained in:
parent
65fd275261
commit
d451b44d26
@ -1,26 +1,20 @@
|
|||||||
#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;
|
||||||
|
char cmpStr[] = "Thrad Zex'lek";
|
||||||
//Getting input
|
//Getting input
|
||||||
for(int i = 0; i < 50; i++){
|
while(1){
|
||||||
if( poll(&mypoll, 1, 3000)){
|
scanf("%d %[^\n]", &score[pos], name[pos]);
|
||||||
scanf("%d %[^\n]", &score[pos], name[pos]);
|
scanf("%*c");
|
||||||
scanf("%*c");
|
pos++;
|
||||||
pos++;
|
if(strcmp(name[pos - 1], cmpStr) == 0) break;
|
||||||
int tmpCh = getc(stdin);
|
int tmpCh = getc(stdin);
|
||||||
if(tmpCh == '\n') break;
|
if(tmpCh == '\n') break;
|
||||||
ungetc(tmpCh, stdin);
|
ungetc(tmpCh, stdin);
|
||||||
}
|
|
||||||
else{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char newName[50][50];
|
char newName[50][50];
|
||||||
|
Loading…
Reference in New Issue
Block a user