From a119f138abc592a069ddf1c36b5e907e354c2b3b Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 9 Apr 2020 23:34:05 +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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/du5/program.c b/du5/program.c index ae1bf7a..8d27ae6 100644 --- a/du5/program.c +++ b/du5/program.c @@ -1,7 +1,7 @@ #include #include #include - +#include struct person{ int score; @@ -38,11 +38,16 @@ int main(){ int score=0; int c =0; char str[100]; + char digit[5]; while(fgets(str,100,stdin)){ if(str[0]=='\n'){ break; } - sscanf(str,"%d %[^\t\n]",&score,name); + sscanf(str,"%s %[^\t\n]",digit,name); + if(isalpha(digit[0])!=0){ + break; + } + int score = atoi(digit); PersonList[c].score = score; strcpy(PersonList[c].name ,name); c++;