diff options
author | rafa_99 <rafa99@protonmail.com> | 2020-12-04 03:31:45 +0000 |
---|---|---|
committer | rafa_99 <rafa99@protonmail.com> | 2020-12-04 03:31:45 +0000 |
commit | 7be4deeee60d11e3ae09ddef1147b2a93b183d88 (patch) | |
tree | b566529d788449442b95fe6a2f0ec41e657a7c45 /session.c | |
parent | 650fb220913f79b5016dcfe1e497493619bf6fa2 (diff) |
Pushed Working Board
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -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); } } |