summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'session.c')
-rw-r--r--session.c22
1 files changed, 16 insertions, 6 deletions
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);
}
}