I am writing a program that reads in data from a text file and puts it into a linked list. Certain variables are read in only if the "officeHeld" number is a particular number, otherwise the variable is set to 0. When I run this through Visual Studio, I get a blank black screen with nothing on it. When I run it through our university's unix, I get "segmentation fault". I am not sure where the error is here and I'm at a loss. Any help our suggestion would be overwhelmingly appreciated. I'm attaching the code as well as some of the text file information!
Here is a sample piece of the text document (it's a long one so I'm only including a sample, but if I can get it to read even one in, then it's working correctly)
Text File:
WALLACE, HENRY
IOWA
2
33
1941
1945
WASHINGTON, GEORGE
VIRGINIA
1
01
1789
1797
WHEELER, WILLIAM
NEW YORK
2
19
1877
1881
WILSON, HENRY
NEW HAMPSHIRE
2
18
1873
1877
When officeHeld equals 2 (line 60), you only extract 2 numbers from your file. Given the file segment you posted ( a big help btw), the second time the loop goes around it tries to extract VIRGINIA into officeHeld.
I have fixed the segmentation error. I was adding my nodes to the beginning of the list rather than the end liked I wanted to.
LowestOne, yes, I noticed the error on that and have fixed it to now grabbing 3 variables.
That being said, I am still having problems ADDING the node to the list. When I call my print function, it only prints the first node, meaning those nodes added within the "else" of addOfficial are not being added correctly. I've stepped through the code, but I'm not sure where my error is :( Once again, nothing comes up on Visual Studio as an error or warning. Officials.txt is opening correctly.