-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
50 lines (35 loc) · 1.13 KB
/
main.c
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "main.h"
#include "io.c"
#include "levenshtein.c"
#include "suggestion.c"
/** Main function */
int main()
{
starting_promt();
load_word_list(); /** Calling load_word_list() function to load all words */
while(!feof(stdin)) /** Continues loop until break condition is reached */
{
printf("Press ENTER to continue.\n");
gets(input);
starting_promt();
/** Taking Input from User */
printf("Enter a word in lower case: ");
scanf("%[^\n]", input);
getchar(); /** Takes the newline character from buffer */
putchar('\n');
if(!strcmp(input, "/exit")) /** Breaks loop if input is /exit */
break;
/** Finding suggestions using edit distance algorithm */
edit_distance(input);
/** Checks if there is any element of edit-distance 0 */
if(length[0])
show_meaning(distance[0][0]);
/** If no words match with input, shows some suggestion */
else
suggestion();
putchar('\n');
}
/** Exits the program */
exit_message();
return 0;
}