Advertisement
tkamiten

load_test

Apr 17th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6. typedef struct node
  7. {
  8. char word[46];
  9. struct node* next;
  10. }
  11. node;
  12.  
  13. node* hashtable[100];
  14.  
  15. // initialize hashtable
  16. for(int i = 0; i < 100; i++)
  17. hashtable[i] = NULL;
  18.  
  19. // file pointer to dictionary
  20. FILE *fptr;
  21.  
  22. fptr = fopen("./dictionaries/small","r");
  23.  
  24. node* new_node = malloc(sizeof(node));
  25. fscanf(fptr,"%s",new_node->word);
  26.  
  27. node* new_node2 = malloc(sizeof(node));
  28. fscanf(fptr,"%s",new_node2->word);
  29.  
  30. int index = new_node->word[0] - 'a';
  31. if (hashtable[index] == NULL)
  32. hashtable[index] = new_node;
  33.  
  34. new_node->next = new_node2;
  35.  
  36.  
  37. printf("%s\n",new_node->word);
  38. printf("%s\n",new_node2->word);
  39.  
  40. fclose(fptr);
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement