-
Notifications
You must be signed in to change notification settings - Fork 0
/
suggestion.c
55 lines (45 loc) · 1.15 KB
/
suggestion.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
49
50
51
52
53
/** Function to show word suggestions
* it shows some suggestion and choices
* Afterwards it shows the chosen word meaning
*/
void suggestion()
{
int num = 0, i, j;
printf("The word could not be found in dictionary.\n");
printf("Word suggestion:\n");
for(i = 1; i < MAX_DISTANCE; i++)
{
for(j = 0; j < length[i]; j++)
{
if(num <= NUMBER_OF_SUGGESTIONS)
printf("%3d. %s\n", ++num, dictionary[distance[i][j]].word);
}
}
if(!num)
{
printf("No suggestions found\n");
return;
}
putchar('\n');
int choice;
do
{
printf("Enter your choice: ");
scanf("%d", &choice);
} while(choice < 1 || choice > num);
getchar(); /** Takes newline from buffer */
putchar('\n');
num = 0;
for(i = 1; i < MAX_DISTANCE; i++)
{
for(j = 0; j < length[i]; j++)
{
if(num + 1 == choice) /** To find the matching choice position */
{
show_meaning(distance[i][j]);
return;
}
num++;
}
}
}