Segmentation Fault Reading File Into Hash Table

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 25
Reputation: Daria Shmaria is an unknown quantity at this point 
Solved Threads: 0
Daria Shmaria Daria Shmaria is offline Offline
Light Poster

Segmentation Fault Reading File Into Hash Table

 
0
  #1
May 21st, 2009
I'm writing a spellchecking program using a hash table. The hash table (a char * array) serves as the dictionary, storing words inputted from a file. However, a segmentation fault occurs before I can get through reading, hashing, and inserting all 60,389 words (the words are in alphabetical order, and the fault occurs after "reloads"). Any suggestions on how to figure out where the segmentation fault is coming from would be greatly appreciated.

The attached files:

1. spellcheck.cpp contains the main function, calling the Dictionary class member function "add" on every word in the file wordlist.txt.
2. hashTable.cpp contains definitions for functions in the Dictionary class. The "add" and "getIndex" functions are the only ones that are functional right now.
3. hashTable.h contains declarations.
4. wordlist.txt contains all the words that need to go in the dictionary.
5. input.txt is the input to the program, but isn't actually being used for anything yet.
Attached Files
File Type: cpp spellcheck.cpp (1.9 KB, 19 views)
File Type: cpp hashTable.cpp (4.1 KB, 18 views)
File Type: h hashTable.h (612 Bytes, 17 views)
File Type: txt wordlist.txt (609.3 KB, 12 views)
File Type: txt input.txt (208 Bytes, 12 views)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 25
Reputation: Daria Shmaria is an unknown quantity at this point 
Solved Threads: 0
Daria Shmaria Daria Shmaria is offline Offline
Light Poster

Re: Segmentation Fault Reading File Into Hash Table

 
0
  #2
May 21st, 2009
Er, never mind. I'm not entirely sure what I did that fixed it, but I'm able to read in the whole file now. Sorry for the inconvenience.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC