Guest User

Untitled

a guest
Jul 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. struct data
  2. {
  3.    char *name;
  4.    char *score;
  5. };
  6.  
  7. int counter = 0;
  8. int high = 0;
  9.  
  10. int main(void) {
  11.    struct data Scores[1000];
  12.    while (counter < 1000) {
  13.       char command[9]; //recognize the command, score,highscore,best
  14.       char name[20]; //recognize the name of the person up to 20chars
  15.       char ss[10]; //recognize the score of the person, up to 10 digits
  16.       int i = 0; //used to readstring
  17.          i = readstring(command,9); //read our command
  18.          if(i == 0) break;
  19.          if (strcmp(command,"score") == 0) {
  20.             i = readstring(name,20);
  21.             if(i==0) break;
  22.             Scores[counter].name = name; //record our name into our array use counter
  23.             printf("Hello %s\n",Scores[counter].name);
  24.             i = readstring(ss,10);
  25.             if(i==0) break;
  26.             Scores[counter].score = ss; //record our score into our array use counter
  27.             printf("Your score is %s\n",Scores[counter].score);
  28.             counter++;
  29.          } else if (strcmp(command,"highscore") == 0) {
  30.          } else if (strcmp(command,"best") == 0) {
  31.             i = readstring(name,20);
  32.             printf("Find score for %s\n", name);
  33.             counter++;
  34.          } else {
  35.             printf("move on");
  36.          }
  37.       }
  38.       printf("names at %d: %s\n",0, Scores[0].name);
  39.       printf("Scores for %d: %s\n",0, Scores[0].score);
  40.       printf("current counter iteration: %d\n",counter);
  41.    return 0;
  42. }
Add Comment
Please, Sign In to add comment