* Copyright (c) 1980 Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of California at Berkeley. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)snscore.c 5.2 (Berkeley) %G%";
char *recfile
= "/usr/games/lib/snakerawscores";
struct passwd
*getpwuid();
} players
[MAXPLAYERS
], temp
;
short whoallbest
, allbest
;
fd
= fopen(recfile
, "r");
printf("Snake players scores to date\n");
fread(&whoallbest
, sizeof(short), 1, fd
);
fread(&allbest
, sizeof(short), 1, fd
);
if(fread(&score
, sizeof(short), 1, fd
) == 0)
if (noplayers
> MAXPLAYERS
) {
printf("too many players\n");
players
[noplayers
].uids
= uid
;
players
[noplayers
].scores
= score
;
players
[noplayers
].name
= malloc(strlen(q
)+1);
strcpy(players
[noplayers
].name
, q
);
for (notsorted
=1; notsorted
; ) {
for (i
=0; i
<noplayers
-1; i
++)
if (players
[i
].scores
< players
[i
+1].scores
) {
players
[i
] = players
[i
+1];
for (i
=0; i
<noplayers
; i
++) {
printf("%d:\t$%d\t%s\n", j
, players
[i
].scores
, players
[i
].name
);
if (players
[i
].scores
> players
[i
+1].scores
)