Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct data
- {
- char *name;
- char *score;
- };
- int counter = 0;
- int high = 0;
- int main(void) {
- struct data Scores[1000];
- while (counter < 1000) {
- char command[9]; //recognize the command, score,highscore,best
- char name[20]; //recognize the name of the person up to 20chars
- char ss[10]; //recognize the score of the person, up to 10 digits
- int i = 0; //used to readstring
- i = readstring(command,9); //read our command
- if(i == 0) break;
- if (strcmp(command,"score") == 0) {
- i = readstring(name,20);
- if(i==0) break;
- Scores[counter].name = name; //record our name into our array use counter
- printf("Hello %s\n",Scores[counter].name);
- i = readstring(ss,10);
- if(i==0) break;
- Scores[counter].score = ss; //record our score into our array use counter
- printf("Your score is %s\n",Scores[counter].score);
- counter++;
- } else if (strcmp(command,"highscore") == 0) {
- } else if (strcmp(command,"best") == 0) {
- i = readstring(name,20);
- printf("Find score for %s\n", name);
- counter++;
- } else {
- printf("move on");
- }
- }
- printf("names at %d: %s\n",0, Scores[0].name);
- printf("Scores for %d: %s\n",0, Scores[0].score);
- printf("current counter iteration: %d\n",counter);
- return 0;
- }
Add Comment
Please, Sign In to add comment