Advertisement
Guest User

Untitled

a guest
May 29th, 2015
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. /* open */
  2. fileptr = fopen(filename, "r");
  3.  
  4. /* check for errors opening */
  5. if(!fileptr){
  6. printf("Error opening file.");
  7. }
  8.  
  9. /* get the word */
  10. /* while the input is not at the end */
  11. char *pos = (char *)malloc(sizeof(char));
  12. while((pos = getWord(fileptr)) != NULL){
  13. /* Instruction One: Read in word. Print for verification */
  14. printf("%s", pos);
  15.  
  16. /*Instruction Two: If word is in the hash table, increment occurrences */
  17. if(containsKey(hashTable, pos)){
  18. int val= *atMap(hashTable, pos);
  19. val++;
  20. }
  21. /*instruction Three: If it's not in the hash table, insert it with occurence amount of one */
  22. else{
  23. insertMap(hashTable, pos, 1);
  24. }
  25.  
  26. /* since it's in the while, should inc automatically */
  27. }
  28.  
  29. /*... concordance code ends here ...*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement