Run time error

Last edited on
What's a Project object? What's a Charge object?

Narrow down the problem. You've done well by identifying that removing lines 76 to 98 eliminates the crash. Now look at those lines and figure out exactly which one causes it by. Either with smart guesses (for example, maybe it's the call to appendnode on line 92; what if you just comment that out?).

You could also use the debugger. That would tell you the exact line causing the problem.

Calls to the function
void discard_line(ifstream &in)
    char c;

    while (c!='\n');

can be replaced with a more C++ way of doing it, and the function thrown away. Something like or perhaps or the similarly named string function . That function looks like it was written by someone who was thinking in C rather than thinking in C++.
Last edited on
My professor gave a hint and said that the AppendNode function needs to be done using a template.

Not sure what he / she means. The whole program works without templates why just one for the AppendNode function?????

In my VS 2015 the error occurs at line 97:
Exception thrown: read access violation.
p->Jptr was 0xCDCDCDCD.
cout << p->Jptr->jcode << " " << p->Jptr->descript << " "

Last edited on
could he have said that because there's more linked lists?

I have no idea.
Any way the problem is that when you read the employees first you don't have the job data so the job pointer remains a nullptr. When you print the list a second time the first nodes don't have jobs so you need the check before you try to print.
Topic archived. No new replies allowed.