diff options
Diffstat (limited to '12.c')
| -rw-r--r-- | 12.c | 7 | 
1 files changed, 5 insertions, 2 deletions
@@ -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);  | 
