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++;