From 10f64607e8992052bad3fe29f81ff3e741a79387 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Fri, 1 Jul 2011 16:57:19 +0200 Subject: [PATCH] flexible count of levels --- star.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/star.c b/star.c index cc51a24..f4ba0d5 100644 --- a/star.c +++ b/star.c @@ -422,6 +422,9 @@ int main( int argc, char* argv[] ) int i = 0, lvl = 0, key; struct state *s = malloc( sizeof( struct state ) ); + /* trick to count how many levels we have */ + int nb_levels = sizeof( levels ) / sizeof( levels[ 0 ] ); + /* ncurses */ WINDOW *w_main = initscr( ); cbreak(); @@ -459,7 +462,7 @@ int main( int argc, char* argv[] ) default: break; } - } while( lvl < 25 && (( key != 'q' ) && ( key != 'Q' )) ); + } while( lvl < nb_levels && (( key != 'q' ) && ( key != 'Q' )) ); display_level( s ); free( s );