-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv3.c
1048 lines (922 loc) · 22.5 KB
/
v3.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
C PROGRAM FOR OFFLINE DICTIONARY
AUTHOR: SWAPNIL SAXENA
COMPUTER SCIENCE AND ENGINEERING
JAYPEE INSTITUTE OF INFORMATION TECHNOLOGY
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
#include<time.h>
#include<windows.h>
#define NEWLINE printf("\n") ;
#define AND &&
#define OR ||
// structure for node of dictionary linked list
struct key_val
{
char key[40] ;
long seekto ;
struct key_val *next ;
struct key_val *back ;
};
// we made a structure variable d_node and declared it as a user defined data type
typedef struct key_val d_node ;
// structure related pointer variables
d_node *element = NULL ;
d_node *prev = NULL;
// structure for node of syn_ant
struct node
{
char *syn;
char *ant;
struct node *next;
};
// structure for time
struct performance
{
clock_t start;
clock_t end;
double time_used;
};
// file pointer for dictionary
FILE *f = NULL;
// file pointer for syn_ant
FILE *g = NULL;
// reads the dictionary file line by line
char* fline();
// fline function variables listed here
char data[80], ch;
// reads the syn_ant file line by line
int gline();
// gline function variables listed here
char *line;
// to create the dictionary linked list
void initialize();
// initialize function variable listed here
char *tmpchr , *lastdef = "\0" ;
int number_of_keys = 0 ;
// to create the syn_ant linked list
struct node *ignite();
// return 1 if given string is all capital
int upper(char *ch);
// changes the given string to all capital
void to_upper(char *a);
// creates a node for syn_ant linked list
void make_node(struct node **ref);
// searches for child as a substring in the parent string
char *sub_srch(char *parent, char *child);
// reads the definition given a file pointer
void defread (double where);
// the function returns 0 if input is zero else changes the input to all capital
int input_cap();
//searches for the meaning of the word in dictionary
void meaning(struct node *ptr);
// searches for syn
void syn_meaning(struct node *ptr);
// searches for ant
void ant_meaning(struct node *ptr);
// returns the command to be executed
int command();
// lists all syn_ant data
void show(struct node *a);
// lists all dictionary data
void show_dic();
// deallocates all memory
void all_clear(struct node *a);
// print instructions
void instructions();
// structure to save timing
struct performance stats;
// input variable
char user[40];
// function pointer
void (*fun_ptr)(struct node*);
void main()
{
system("color E3");
int i = 0;
int to_do = 0;
f = fopen("final_dict.txt","r");
g = fopen("ant_syn.txt","r");
// initialise function pointer
fun_ptr = &(meaning);
// intial code for dictionary
d_node *head ;
head = (d_node *)malloc(sizeof(d_node)) ;
// we saved the head address in the global structure d_node pointer variable element
element = head ;
// the initialize function would import the data from the file to the linked list
initialize() ;
element = head ;
// initial code for syn_ant
struct node *start = (struct node*)calloc(sizeof(struct node),1);
// save the address of start
start = ignite();
NEWLINE
NEWLINE
printf("PRESS ANY KEY TO CONTINUE...\n");
//get delay
getch();
//clear console
system("cls");
//show(start);
instructions();
getch();
while(1)
{
//label
come_again:
// clear console
system("cls");
printf("INPUT: ");
scanf("%s",user);
// change to capital
input_cap();
// clear console
system("cls");
to_do = command();
switch(to_do)
{
case 0:
// clear the console
system("cls") ;
element = head;
all_clear(start);
printf("MEMORY DEALLOCATED SUCCESSFULLY !!!");
printf("\nPRESS ANY KEY TO CONTINUE...\n");
// get delay
getch();
// clear the console
system("cls") ;
fclose(f);
fclose(g);
printf("BOTH FILES CLOSED SUCCESSFULLY !!!\n");
printf("\nPRESS ANY KEY TO CONTINUE...\n");
// get delay
getch();
system("cls") ;
printf("PROGRAM TERMINATED SUCCESSFULLY !!!\n\n");
printf("\nPRESS ANY KEY TO CONTINUE...\n");
// get delay
getch();
exit(0);
case 1:
meaning(NULL);
// reset pointer
element = head;
goto come_again;
break;
case 2:
syn_meaning(start);
goto come_again;
break;
case 3:
ant_meaning(start);
goto come_again;
break;
case 4:
// it means mode has been changed hence take the input again
goto come_again;
break;
case 5:
// list all words
// reset element
element = head;
show_dic();
printf("\n\nPRESS ANY KEY TO CONTINUE !!!\n");
getch();
system("cls");
goto come_again;
break;
case 6:
// list all syn_ant
show(start);
printf("\n\nPRESS ANY KEY TO CONTINUE !!!\n");
getch();
system("cls");
goto come_again;
break;
default:
//pass
break;
}
}
}
char *fline()
{
int i ;
for (i=0;i<80;i++)
{
data[i]='\0' ;
}
i = 0 ;
do
{
ch = getc(f);
if(ch=='\n')
{
break ;
}
data[i] = ch;
i++ ;
}
while( ( i < 80 ) AND ( ch != EOF ) AND ( ch != '\n') ) ;
// i < 80 in do while loop means 0 to 79 (not 80) since condition evaluated at last hence last charachter always null
return data ; // the return string pointer wont have charachter such as \n
}
int gline()
{
long start_line = ftell(g); // stores the start of each line
int i = 0; //i would serve as counter
int l = 0; // saves the lenght
char ch = getc(g); // read charachter by charachter
while(1)
{
if (ch == '\n')
{
break;
}
if (ch == EOF)
{
break;
}
i++;
ch = getc(g);
}
l = i ; //save the lenght
fseek(g,start_line,0); // reset pointer to start of current line
line = (char*)calloc(sizeof(char),l+1); // allocate memory, 1 extra bit for null charachter
i = 0; //reset counter
ch = getc(g); // start fetching charachters again
while(( i < l ) AND ( ch != EOF ))
{
if((ch >= 97) AND (ch <= 122))
{
// convert lower to upper case
ch = ch-32;
}
line[i] = ch;
ch = getc(g);
i++;
}
line[i] = '\0'; // set null
return l;
}
void initialize ()
{
//initialize clock
stats.start = clock();
// feof is true when end of file is reached
// while loops until true
// hence not-feof means condition would be false when end of file is reached
tmpchr = fline() ;
while ( !(feof(f)) )
{
if ( upper(tmpchr) == 1 )
{
int i = 0 ; // counter for element key
int j = 0 ; // counter for tmpchr
// copying word charachter by charachter
while( ( *(tmpchr+j) != '\0' ) AND ( j < 80) AND ( (tmpchr+j) != NULL ) AND ( *(tmpchr+j) != ';') AND ( i < 40 ) )
{
if ( ( *(tmpchr+j) == ' ') OR ( *(tmpchr+j) == '-') OR ( *(tmpchr+j) == '_') OR ( *(tmpchr+j) == '.') OR
( *(tmpchr+j) == '\'') )
{
j++ ;
continue ;
}
else if ( 65 <= *(tmpchr+j) <= 90 )
{
(element->key)[i] = *(tmpchr+j) ;
i++ ;
j++ ;
}
else
{
break ;
}
}
// sets the last element as null pointer
if(i==40)
{
i--;
}
(element->key)[i] = '\0' ;
// if it is a duplicate then we would skip to next word
if ((strcmp(lastdef,element->key)) == 0 )
{
// strcmp returns 0 is strings are equal
// we continue the loop
// increase the file pointer to next line
tmpchr = fline(f) ;
// for next iteration
continue ;
}
else
{
// this else code is run when c encounters the first distinct copy of a word
// copy current key address to lastdef for later checking
lastdef = (element->key) ;
number_of_keys += 1 ;
//printf("%s",element->key) ;
//NEWLINE
}
{
// now the file pointer points to defintion part so we save the location
element->seekto = ftell(f) ;
// create next d_node
element->next = (d_node *)malloc(sizeof(d_node)) ;
// assign previous d_node address to structure pointer back
element->back = prev ;
// save current d_node address in global structure pointer element prev to be used in next element for previous pointter
prev = element ;
// assign address of next element to gloabl structure d_node variable element
element = (element->next) ;
// increase file pointer to next line and save in gloabl char pointer variable tmpchr
tmpchr = fline(f) ;
}
}
else
{
while(!(upper(tmpchr)))
{
// we want the loop to end as soon as upper(ptr) returns 1 i.e true
if(feof(f))
{
// free the memory allocated for last most pointer defintion
free(element->next) ;
// set last element next pointer to null
element->next = NULL ;
printf("DICTIONARY INFORMATION");
printf("\nIMPORT COMPLETED SUCCESSFULLY");
NEWLINE
stats.end = clock();
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\nTIME TAKEN TO IMPORT DATA = %lf SECONDS",stats.time_used);
printf("\nNUMBER OF WORDS IMPORTED = %d",number_of_keys);
printf("\nAVERAGE SPEED RECORDED = %f WORDS PER SECOND",(number_of_keys/stats.time_used));
printf("\nTIME NEEDED TO IMPORT ONE WORD = %f SECONDS\n\n",(stats.time_used/number_of_keys));
//system("cls") ;
return ;
}
tmpchr = fline(f) ;
}
}
}
}
struct node *ignite()
{
// initialise clock
stats.start = clock();
int i = 0;
struct node *head;
head = (struct node*)calloc(sizeof(struct node),1);
struct node *ptr;
ptr = head;
while(!feof(g))
{
make_node(&ptr);
i++;
ptr = ptr->next;
if(ptr->syn)
{
//printf("SYN : %s\n",ptr->syn);
}
if(ptr->ant)
{
//printf("ANT : %s\n",ptr->ant);
}
//printf("NODE CREATED !!!\n\n");
}
// end the linked list
ptr->next = NULL;
NEWLINE
NEWLINE
printf("SYNONYMS AND ANTONYMS INFORMATION");
printf("\nIMPORT COMPLETED SUCCESSFULLY");
NEWLINE
//system("cls") ;
stats.end = clock();
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\nTIME TAKEN TO IMPORT DATA = %lf SECONDS",stats.time_used);
printf("\nNUMBER OF ENTITIES IMPORTED = %d",i);
printf("\nAVERAGE SPEED RECORDED = %f ENTITIES PER SECOND",(i/stats.time_used));
printf("\nTIME NEEDED TO IMPORT ONE WORD = %f SECONDS\n\n",(stats.time_used/i));
return (head->next) ;
}
int upper(char *ch)
{
int i =0 ; // pointer counter
if (*ch == NULL OR *ch == EOF)
{
return 0 ;
}
while( *(ch+i) != '\0' AND i<80 )
// we are pretty sure that our charachter string pointer will never point to \n charachter and end at \0
{
if ( ((int)(*(ch+i)) <= 122 AND (int)(*(ch+i)) >= 97) OR ((int)(*(ch+i)) <= 57 AND (int)(*(ch+i)) >= 48))
// ASCII code range of small letters and numbers
{
return 0 ;
}
else
{
i++ ; // 0 means false i.e presence of any other letter means charachter isnt fully capital
}
}
return 1 ; // return 1 means true that charachter string is fully capital
}
void to_upper(char *arr)
{
while( *(arr) != '\0' )
{
if( ( (*arr) >= 97 ) AND ( (*arr) <= 122 ) )
{
*arr = (*arr)-32;
}
arr++;
}
return;
}
void make_node(struct node **ref)
{
struct node *ptr = *ref;
ptr->next = (struct node*)calloc(sizeof(struct node),1); // ptr is a node that already exists
ptr = ptr->next; // ptr now points to the new node
// initialise
ptr->syn = NULL;
ptr->ant = NULL;
int l = 0; // lenght of line
int i = 0; //counter
int key_size = 0;
char key[30];
while(1)
{
l = gline(); // read next line
if ( l == 0 )
{
// when nothing or newline is encountered
// l = 0 therefore coninue
continue;
}
else if ( l == 1 )
{
// if l = 1 then it means we encountered an equal to sign
return;
}
else
{
// do nothing
}
// NEW IF ELSE CONDITIONS
if ((line[0] == 'K') AND (line[1] == 'E') AND (line[2] == 'Y'))
{
//printf("\n->IN KEY\n");
key_size = l ;
if (key_size > 30)
{
key_size = 30;
}
// initialise the key array
for(i=0;i<30;i++)
{
key[i] = '\0';
}
// as we have to read from 6th charachter
i = 5 ;
while(line[i] != '\0')
{
if(((line[i] >= 65) AND (line[i] <= 90)) OR ((line[i] >= 65) AND (line[i] <= 90))
OR (line[i] == ' ') OR (line[i]== ':'))
{
key[i-5] = line[i];
i++;
}
else
{
break;
}
}
//set null
key[i-5] = '\0';
//printf("\n\n ->KEY CREATED !!!\n\n");
}
else if ((line[0] == 'S') AND (line[1] == 'Y') AND (line[2] == 'N'))
{
ptr->syn = (char*)calloc(sizeof(char),l+key_size+5 ); // the l+key_size is more than enough for all operations
// initialise the array
for(i=0;i<(l+key_size);i++)
{
(ptr->syn)[i] = '\0';
}
// copy all elements starting from 5 th character i.e include the space
i = 4;
while(1)
{
if ((line[i] == '\0') OR (line[i] == '.'))
{
break;
}
(ptr->syn)[i-4] = line[i];
i++;
}
//insert null again
(ptr->syn)[i-4] = ',';
i++;
(ptr->syn)[i-4] = ' ';
i++;
// elements copied
// new copy elements from key by
for(int k = 0 ; k <(key_size-4);)
{
(ptr->syn)[i-4] = key[k];
i++;
k++;
}
//insert full stop
(ptr->syn)[i-4] = '.';
i++;
//insert null again
(ptr->syn)[i-4] = '\0';
}
else if ((line[0] == 'A') AND (line[1] == 'N') AND (line[2] == 'T'))
{
ptr->ant = (char*)calloc(sizeof(char),l+5);
// initialise the array
for(i=0;i<(l+1);i++)
{
(ptr->ant)[i] = '\0';
}
// copy all elements starting from 5 th character i.e include the space
i = 4;
while(1)
{
if (line[i] == '\0')
{
break;
}
(ptr->ant)[i-4] = line[i];
i++;
}
//insert null again
(ptr->ant)[i] = '\0';
// elements copied
}
else
{
continue;
}
}
}
char *sub_srch(char *str, char *sub)
{
char *p1, *p2, *p3;
int i=0,j=0,flag=0;
//initialise the char pointers to the arguments
p1 = str;
p2 = sub;
if((p1 == NULL) OR (p2 == NULL))
{
// if any of the pointer is null
return NULL;
}
//printf("%s\n\n",str);
for(i = 0; i<strlen(str); i++)
{
if(*p1 == *p2)
{
p3 = p1;
for(j = 0;j<strlen(sub);j++)
{
if(*p3 == *p2)
{
p3++;p2++;
}
else
{
break;
}
}
p2 = sub;
if(j == strlen(sub))
{
if(((*p3==',') OR (*p3=='.')) AND (*(p3-j-1)==' '))
{
// to check that the substring is a word
flag = 1;
return str;
}
}
}
p1++;
}
if (flag == 0)
{
return NULL;
}
else
{
return str;
}
}
void defread (double where)
{
fseek(f,where,0) ;
tmpchr = fline(f) ;
while( (upper(tmpchr) == 0) AND (!(feof(f))) )
{
printf("%s",tmpchr );
NEWLINE
// increase file pointer
tmpchr = fline(f) ;
}
}
int input_cap()
{
int i = 0 ;
char *s = user ;
while( ( i < 40 ) AND ( *( s + i ) != '\0') )
{
if ( ( *( s + i ) >= 97 ) AND ( *( s + i ) <= 122 ) )
{
*( s + i ) -= 32 ;
}
else if ( ( *( s + i ) >= 65 ) AND ( *( s + i ) <= 90 ) )
{
// continue
}
else
{
return 0 ;
}
i++ ;
}
return 1 ;
}
void meaning(struct node *ptr)
{
stats.start = clock();
// the argument does nothing but brings uniformity about the functions
int i = 0;
// the following loop checks all the words
for( i = 0; i < number_of_keys ; i++ )
{
if(strcmp(user,element->key)==0)
{
stats.end = clock();
system("cls") ;
printf("%s\n\n",user);
NEWLINE
// to print out the definition
defread(element->seekto) ;
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\n\n\nTIME TAKEN TO COMPLETE QUERY = %lf",stats.time_used);
printf("\n\nPress any key to continue...");
// to create delay
getch() ;
break ;
}
else
{
// increase element pointer
element = element->next ;
}
}
stats.end = clock();
// if he loop runs fully w/o break then the following condition is true
// this happens only when word is not found
if( i == number_of_keys )
{
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\n\n\nTIME TAKEN TO COMPLETE QUERY = %lf",stats.time_used);
printf("\n\nCould not find the word");
printf("\n\nPress any key to continue...");
getch() ;
}
}
void syn_meaning(struct node *ptr)
{
stats.start = clock();
int flag = 0;
while(ptr != NULL)
{
char *result;
result = sub_srch(ptr->syn,user);
if (result != NULL)
{
printf("%s ",result);
flag ++;
//break;
}
result = sub_srch(ptr->ant,user);
if (result != NULL)
{
flag++;
printf("%s ",result);
//break;
}
ptr = ptr->next;
}
stats.end = clock();
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\n\n\nTIME TAKEN TO COMPLETE QUERY = %lf",stats.time_used);
// create delay
if(flag==0)
{
printf("\n\nCOULD NOT FIND THE WORD");
}
printf("\n\n\nPRESS ANY KEY TO CONTINUE...");
getch();
system("cls");
}
void ant_meaning(struct node *ptr)
{
stats.start = clock();
int flag = 0;
while(ptr != NULL)
{
char *result;
result = sub_srch(ptr->syn,user);
if (result != NULL)
{
flag++;
printf("%s ",ptr->ant);
//break;
}
result = sub_srch(ptr->ant,user);
if (result != NULL)
{
flag++;
printf("%s ",ptr->syn);
//break;
}
ptr = ptr->next;
}
stats.end = clock();
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\n\n\nTIME TAKEN TO COMPLETE QUERY = %lf",stats.time_used);
if(flag==0)
{
printf("\n\nCOULD NOT FIND THE WORD");
}
// create delay
printf(".\n\n\nPRESS ANY KEY TO CONTINUE...");
getch();
system("cls");
}
int command()
{
if (user[0] == '0')
{
return 0;
}
else if ((user[0] == '-') AND (user[1] == '>') AND (user[2] == 'D') AND (user[3] == 'I') AND (user[4] == 'C') AND (user[5] == '\0'))
{
fun_ptr = &(meaning);
printf("DICTIONARY MODE INITIATED !!!\n");
printf("PRESS ANY KEY TO CONTINUE...\n");
//create delay
getch();
system("cls");
return 4;
}
else if ((user[0] == '-') AND (user[1] == '>') AND (user[2] == 'S') AND (user[3] == 'Y') AND (user[4] == 'N') AND (user[5] == '\0'))
{
fun_ptr = &(syn_meaning);
printf("SYNONYM MODE INITIATED !!!\n");
printf("PRESS ANY KEY TO CONTINUE...\n");
//create delay
getch();
system("cls");
return 4;
}
else if ((user[0] == '-') AND (user[1] == '>') AND (user[2] == 'A') AND (user[3] == 'N') AND (user[4] == 'T') AND (user[5] == '\0'))
{
fun_ptr = &(ant_meaning);
printf("ANTONYM MODE INITIATED !!!\n");
printf("PRESS ANY KEY TO CONTINUE...\n");
//create delay
getch();
system("cls");
return 4;
}
else if ((user[0] == '-') AND (user[1] == '>') AND (user[2] == 'W') AND (user[3] == 'R') AND (user[4] == 'D') AND (user[5] == '\0'))
{
fun_ptr = &(ant_meaning);
printf("ABOUT TO LIST ALL THE WORDS OF DICTIONARY !!!\n");
printf("PRESS ANY KEY TO CONTINUE...\n");
//create delay
getch();
system("cls");
return 5;
}
else if ((user[0] == '-') AND (user[1] == '>') AND (user[2] =='A') AND (user[3] == 'S') AND (user[4] == 'A') AND (user[5] == '\0'))
{
fun_ptr = &(ant_meaning);
printf("ABOUT TO LIST ALL THE SYNONYMS AND ANTONYMS !!!\n");
printf("PRESS ANY KEY TO CONTINUE...\n");
//create delay
getch();
system("cls");
return 6;
}
else if ((user[0] == '-') AND (user[1] == '>'))
{
printf("UNKNOWN COMMAND !!!\n");
printf("PRESS ANY KEY TO CONTINUE...\n");
//create delay
getch();
system("cls");
return 4;
}
else
{
if (fun_ptr == &(meaning))
{
return 1;
}
else if (fun_ptr == &(syn_meaning))
{
return 2;
}
else if (fun_ptr == &(ant_meaning))
{
return 3;
}
else
{
return 1;
}
}
}
void show(struct node *ptr)
{
stats.start = clock();
while(ptr != NULL)
{
printf("SYN : %s\n",ptr->syn);
printf("ANT : %s\n",ptr->ant);
printf("\n\n");
ptr = ptr->next;
}
stats.end = clock();
stats.time_used = ((double)(stats.end - stats.start)) / CLOCKS_PER_SEC ;
printf("\n\n\nTIME TAKEN TO COMPLETE QUERY = %lf",stats.time_used);
}
void show_dic()
{
stats.start = clock();
while(1)
{
if(element->next)
{
printf("%s\n",element->key);
//defread(element->seekto);