From 7a2bca0aa45a53d1494b6e9946db9dc3e4999910 Mon Sep 17 00:00:00 2001
From: Leonardo Krambeck <lk19@inf.ufpr.br>
Date: Fri, 18 Oct 2019 04:20:19 -0300
Subject: [PATCH] =?UTF-8?q?arruma=20melhor=20o=20bug=20das=20strings=20mas?=
 =?UTF-8?q?=20ainda=20n=C3=A3o=20resolve=20100%?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 GameOfLife.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/GameOfLife.c b/GameOfLife.c
index d2c1e77..807445a 100644
--- a/GameOfLife.c
+++ b/GameOfLife.c
@@ -113,27 +113,21 @@ void memoryAlloc (game_t *game)
 void firstGeneration (game_t *game)
 {
 	int i=1;
-	char input[] = {'i'};
-
-	while ( !(input[0] == 's' && strlen(input) != 1) )
+	char input = 'i';
+	/* arrumar esses diabo de char */
+	while ( input != 's' )
 	{
 		clear ();
 		printGeneration (game);
 		
 		printf ("\nDigit [a] to add a live cell, [k] to kill a live cell and [s] to start the game.\n");
-		scanf ("%c", input);
+		scanf ("  %c", &input);
 
-		if (input[0] == 'a' && strlen(input) == 1)
+		if (input == 'a')
 			addCell (game, &i);
 
-		else if (input[0] == 'k' && strlen(input) == 1)
+		else if (input == 'k')
 			removeCell (game, &i);
-
-		else if (input[0] != 's' && strlen(input) != 1)
-		{
-			printf ("\nInvalid input, try again.");
-			sleep (2);
-		}
 	}
 }
 
-- 
GitLab