blob: e3b87022b11a05ae6a91b9e7728e242ab82d9c25 (
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
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils.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 GOODBYE to exit\n\n");
while( strcmp(question, "GOODBYE\n") != 0 )
{
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);
}
}
|