From 7be4deeee60d11e3ae09ddef1147b2a93b183d88 Mon Sep 17 00:00:00 2001 From: rafa_99 Date: Fri, 4 Dec 2020 03:31:45 +0000 Subject: Pushed Working Board --- session.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'session.c') diff --git a/session.c b/session.c index b04958d..205e92f 100644 --- a/session.c +++ b/session.c @@ -8,15 +8,25 @@ void startSession(FILE *dictionary) if ( dictionary != NULL ) { int totalWords = lineCounter(dictionary); - char *word; + char *word, *question = (char *) calloc(MAX_LINE, sizeof(char));; char reload = '\0'; - while( reload != 'q' ) + printf("WELCOME\n" + "Type GOODBYE to exit\n\n"); + + while( strcmp(question, "GOODBYE\n") != 0 ) { - word = getLine(dictionary, getRandomNumber(1, totalWords)); - printf("%s", word); - free(word); - reload = getchar(); + printf("Enter a question: "); + fgets(question, MAX_LINE, stdin); + + if ( strcmp(question, "GOODBYE\n") != 0 ) + { + word = getLine(dictionary, getRandomNumber(1, totalWords, question)); + printf("-> %s", word); + free(word); + } } + + free(question); } } -- cgit v1.2.3