summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--12.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/12.c b/12.c
index c647410..42d63d4 100644
--- a/12.c
+++ b/12.c
@@ -136,7 +136,7 @@ main()
range[front->x + front->y * cols] |= 0x80;
// Take steps, widening the search front each iteration.
- for (steps = 0; 1; ++steps) {
+ for (steps = 0; front != NULL; ++steps) {
struct pos * nextfront = NULL;
struct pos * loc;
@@ -166,7 +166,10 @@ main()
front = nextfront;
}
- printf("Found end at %d,%d in %d steps\n", front->x, front->y, steps);
+ if (front)
+ printf("Found end at %d,%d in %d steps\n", front->x, front->y, steps);
+ else
+ printf("No end found after %d steps\n", steps);
pos_free(front);
free(range);