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!
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.