Click to See Complete Forum and Search --> : Need some help in figuring out a seg fault...


Duh
10-13-2002, 01:27 PM
Basically this program makes two linked list queues, and makes them a fake printer queue. A low priority queue, and a sorted high priority queue (by size ascending). The code is easy to figure out, but i keep getting seg faults in different spots, im very confused now.
heres the app code (the list code is given, but i know it all works correctly. functions are pretty self explanatory). the input data we need to use is posted after the code.
Thanks in advance for any help!!!
--------------------


EDIT!!!!

It no longer seg faults, but i get an infinite loop when calling 'delete [] file;'
without it it works fine, but thats a lot of wasted memory

truls
10-13-2002, 01:55 PM
In destructor of Data it should read:
delete[] file;
Other than that I would need the code for the LList to compile and check it out (the memory allocation confuses me, but maybe this is handled in the LList class.

Don't make the members public, but create a fill() method that takes the stream as input and fills in the members. That way it's easy to debug and check the input.

Duh
10-13-2002, 02:05 PM
FYI the latest seg fault i got was related to the new char pointer array. (line 36).
so i changed it all to be a normal char array, not a pointer and no seg faults. so i know it has something to do with the file pointer. but it needs to be a pointer according to the prof.
i have the .o and header files for the LList class, but not the function code.