Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct node
- {
- char word[46];
- struct node* prev;
- struct node* next;
- };
- struct node *d[52];
- struct node *conductor;
- for (int i=0; i<sizeof(d); i++)
- {
- d[i]= (struct node *) malloc( sizeof(struct node) );
- }
- FILE* in = fopen("dictionary","r");
- int first, second, i = 0; /* i=index*/
- char w[46]; /* w= word of maximum length 45 */
- while ((fputs (w,in))!= EOF)
- {
- first = atoi(&w[0]) - 97;
- second = atoi(&w[1]) - 97;
- if (second < 14)
- {
- i=first*2;
- }
- else
- {
- i=first*2+1;
- }
- if (d[i]->next != NULL)
- {
- strcpy(d[i]->word,w);
- d[i]->next=NULL;
- }
- else
- {
- conductor= d[i];
- conductor->prev=(struct node *) malloc( sizeof(struct node) );
- conductor=conductor->prev;
- conductor->next=d[i];
- d[i]=conductor;
- strcpy(d[i]->word,w);
- }
- }
- fclose (in);
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement