/* show-hiscore.c -- The main function for get_highscore(). Created on: 2008/11/28 18:40:56 ~yas/dsys/highscore/centralized/show-hiscore.c */ #include /* stderr, fprintf() */ #include /* strtol() */ #include "highscore.h" static void show_score( int top ); static void usage( char *comname ) { fprintf(stderr,"Usage: %% %s n\n", comname); exit( 1 ); } main( int argc, char *argv[], char *envp[] ) { int top; char *name ; if( argc != 2 ) usage( argv[0] ); top = strtol( argv[1], 0, 10); show_score( top ); } static void show_score( int top ) { score_record_t records[HIGHSCORE_MAX_RECORDS]; int n, i ; if( top > HIGHSCORE_MAX_RECORDS ) { fprintf(stderr,"Warning: top too large: %d\n",top); top = HIGHSCORE_MAX_RECORDS; } n = get_highscore( records, top ); for( i=0; i