From 76166d46a9c66e20ff0c1cfa6a6c36c46958fbcf Mon Sep 17 00:00:00 2001 From: Tom Deakin Date: Mon, 24 Nov 2014 10:30:17 +0000 Subject: [PATCH] Update exercise 13 --- Exercises/Exercise13/C/gameoflife.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Exercises/Exercise13/C/gameoflife.c b/Exercises/Exercise13/C/gameoflife.c index f8a3b18..fe3a3a2 100644 --- a/Exercises/Exercise13/C/gameoflife.c +++ b/Exercises/Exercise13/C/gameoflife.c @@ -187,13 +187,13 @@ void load_board(char* board, const char* file, const unsigned int nx, const unsi int retval; unsigned int x, y, s; - while ((retval = fscanf(fp, "%d %d %d\n", &x, &y, &s)) != EOF) + while ((retval = fscanf(fp, "%u %u %u\n", &x, &y, &s)) != EOF) { if (retval != 3) die("Expected 3 values per line in input file.", __LINE__, __FILE__); - if (x < 0 || x > nx - 1) + if (x > nx - 1) die("Input x-coord out of range.", __LINE__, __FILE__); - if (y < 0 || y > ny - 1) + if (y > ny - 1) die("Input y-coord out of range.", __LINE__, __FILE__); if (s != ALIVE) die("Alive value should be 1.", __LINE__, __FILE__);