Hi everyone, I'm trying to finish this program that will read in 15 names and then hash them using a hash class. My problem is that I can't figure out what is wrong with my insert function. During execution it will get to the use of the insert function and get a segmentation fault. If the use of the insert function is commented out, it will work just fine.
One problem I see is in the while loop at lines 84-95. At line 93 you increment pos with no check as to whether you've reached the end of the array. Consider the iteration through the loop when pos = 22. Line 93 increments pos to 23 and returns to the top of the loop. Line 86 then proceeds to reference a[23] which is not a valid element of the array. Valid elements are 0-22.
Well looking at it now, I realize that my logic is backwards. If the element in a[pos] is equal to a question mark, then the word should be stored there.The while loop should be enacted if the position isn't a question mark. I agree to that my while loop may need some revision.
I don't understand why the the program won't even reach the insert function though.