blob: d847c993ac977eee3ad4f2079a547e313b593bc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "utils.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void
startSession (FILE *dictionary)
{
if (dictionary != NULL)
{
int totalWords = lineCounter (dictionary);
char *word, *question = (char *)calloc (MAX_LINE, sizeof (char));
char reload = '\0';
printf ("WELCOME\n"
"Type something to get an answer\n"
"Type GOODBYE to exit\n\n");
while (strcmp (question, "GOODBYE\n") != 0)
{
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);
}
}
|