Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8937137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:21:23+00:00 2026-06-15T10:21:23+00:00

My code is below, and my problem occurs when I am trying to loadFile

  • 0

My code is below, and my problem occurs when I am trying to “loadFile” through my program. It asks me for the filename, and when I give it a filename that it can find, it just says “Segmentation Fault” and stops running. I think the problem is either coming from the loadFile method itself or on line 244 which is where I’m writing the method for adding an element to the linkedlist. Any help is appreciated! Thanks.

http://pastebin.com/7qZY9Hef

Line 224:

 void countyElectionList::push_back(countyElectionResults * newCER){

    if(head == NULL)
head = newCER;
else
    {
    countyElectionResults * current = head;
    while(current->getNextResult() != NULL){
        current = current->getNextResult();
    }
current->setNextResult(newCER);
}

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:21:23+00:00Added an answer on June 15, 2026 at 10:21 am

    According to the source code at the URL you linked (which also will not compile for a number of reasons, including missing brackets and functions missing return statements, among other things) the problem is here:

    // A constructor that initializes the private data members
    countyElectionList::countyElectionList(){
    
    }
    

    You never initialize countyElectionList::head to NULL, so when you call countyElectionList::push_back the value of head will most likely not point to NULL but to who-knows-what… hence the crash.

    For future reference: when you debug crashes if the function in which the crash occurs doesn’t look suspicious and you can’t find a fault with the source code and in stepping through the logic step-by-step, you should move on to examining the caller(s) of the function.

    Update: So, after examining your new pastebin code (which still does not compile, as several functions which claim to return values lack return statements) the error continues to be in the same function:

    // A constructor that initializes the private data members
    countyElectionList::countyElectionList(){
        countyElectionList::head == NULL;
    }
    

    Notice that you using == which is the comparison operator and not the assignment operator, which is =. This is the correct code to use:

    // A constructor that initializes the private data members
    countyElectionList::countyElectionList(){
        head = NULL;
    }
    

    I have to wonder if you actually even tried to compile this code. I did, and my compiler immediately pointed the error out to me. It even told me what to do:

    test.cpp(210) : warning C4553: ‘==’ : operator has no effect; did you
    intend ‘=’?

    I also suspect that you are in way over your head. I am assuming that this is homework and you’re not doing an actual election system (although…) so I guess my next question is: have you considered talking to your professor and explaining how you having difficulty with the syntax of the language? Perhaps your school has resources that could help. Trying to program by randomly inserting stuff in a file doesn’t help you learn; it’s an exercise in frustration.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to display a text using the code below. The problem is that
Update: The problem below occurs when I add: <script src=http://code.jquery.com/jquery-1.7.1.min.js></script> I'm trying to redirect
The code below is (hopefully) a minimized testcase of my original problem. I'm trying
i am opening jQuery Dialog through the below code.The problem here is when i
I'm trying to do many-to-many mapping, but have a problem with a code below.
I got a problem when analyzing my code below : NSDate *formatterDate = [inputFormatter
The code below is working, but with a problem I do not understand. When
What is the problem with my code below? It's not returning any items even
Please see my pseudo-code below. The code comments should explain my problem. I'm new
I am having a very specific problem in JQuery The code below is used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.