Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(void)
- {
- typedef struct node
- {
- char word[46];
- struct node* next;
- }
- node;
- node* hashtable[100];
- // initialize hashtable
- for(int i = 0; i < 100; i++)
- hashtable[i] = NULL;
- // file pointer to dictionary
- FILE *fptr;
- fptr = fopen("./dictionaries/small","r");
- node* new_node = malloc(sizeof(node));
- fscanf(fptr,"%s",new_node->word);
- node* new_node2 = malloc(sizeof(node));
- fscanf(fptr,"%s",new_node2->word);
- int index = new_node->word[0] - 'a';
- if (hashtable[index] == NULL)
- hashtable[index] = new_node;
- new_node->next = new_node2;
- printf("%s\n",new_node->word);
- printf("%s\n",new_node2->word);
- fclose(fptr);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement