-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreHistory.c
More file actions
131 lines (123 loc) · 2.5 KB
/
Copy pathScoreHistory.c
File metadata and controls
131 lines (123 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Program : ScoreHistory
// Author : Adriana Anggita Daeli & Pamudya Putra Pamungkas
// Description : Module for showing scores history
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <conio.h>
#include <windows.h>
void gotoxy(int x, int y)
//Mencari posisi suatu koordinat pada layar
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
typedef struct {
char date[26];
char time[10];
char name[10];
char enter;
int score;
}score;
void ScoreHistory(){
FILE *fscore;
int iscore = 1;
int i;
score skor;
// time(&skor.time);
if((fscore=fopen("HighScore.txt", "rb"))==NULL){
printf("File tidak dapat dibuka\n");
exit(1);
}
printf("\t\t\tRiwayat Skor Monopoli\n");
for(i=0;i<65;i++){
switch(i){
case 0:
printf("%c", 201);
break;
case 8:
printf("%c", 203);
break;
case 30:
printf("%c", 203);
break;
case 40:
printf("%c", 203);
break;
case 64:
printf("%c", 187);
break;
default :
printf("%c", 205);
break;
}
}
printf("\n%cNo. \t%c DD/MM/YYYY HH:MM:SS %c Names\t%c \t Scores\t\t%c\n",186,186,186,186,186);
for(i=0;i<65;i++){
switch(i){
case 0:
printf("%c", 204);
break;
case 8:
printf("%c", 206);
break;
case 30:
printf("%c", 206);
break;
case 40:
printf("%c", 206);
break;
case 64:
printf("%c", 185);
break;
default :
printf("%c", 205);
break;
}
}
printf("\n");
fscanf(fscore, "%s %s %s %d%c",&skor.date,&skor.time,&skor.name,&skor.score,&skor.enter);
while(!feof(fscore)){
printf("%c%d.\t%c %s %s %c %s\t%c\t\t\t%c\n",186,iscore,186,skor.date,skor.time,186,skor.name,186,186);
fscanf(fscore, "%s %s %s %d%c",&skor.date,&skor.time,&skor.name,&skor.score,&skor.enter);
iscore++;
}
for(i=0;i<65;i++){
switch(i){
case 0:
printf("%c", 200);
break;
case 8:
printf("%c", 202);
break;
case 30:
printf("%c", 202);
break;
case 40:
printf("%c", 202);
break;
case 64:
printf("%c", 188);
break;
default :
printf("%c", 205);
break;
}
}
rewind(fscore);
iscore = 0;
fscanf(fscore, "%s %s %s %d%c",&skor.date,&skor.time,&skor.name,&skor.score,&skor.enter);
while(!feof(fscore)){
gotoxy(48,4+iscore); printf("%d", skor.score);
fscanf(fscore, "%s %s %s %d%c",&skor.date,&skor.time,&skor.name,&skor.score,&skor.enter);
iscore++;
}
gotoxy(0, 3+iscore); printf ("\n");
}
int main(){
ScoreHistory();
return 0;
}