hey guys so i seem to be having issue with my code, We need to make a doubly circularly linked list, but i cannot for the life of me seem to get my populate function to work with my add name function any ideas
#include <iostream>
#include <fstream>
using namespace std;
entry_t *temp = List->next;
entry_t *temp2 = List;
int found = 0;
for(temp = List; temp != NULL; temp = temp->next, temp2 = temp2->next){
temp->next = new entry_t; // takes the pointer and tells it to go to the next entry
temp->next->fname = fname;
temp->next->lname = lname;
temp->next->year = year;
cout << endl;
temp->next->next = 0;
temp->next->previous = temp; // this is how it goes backwards which is important to the doubly linked list
}
}
else{
// if there is no list then make one
HEAD = new entry_t;
HEAD->fname = fname;
HEAD->lname = lname;
HEAD->year = year;
HEAD->next = 0;
HEAD->previous = 0;
void deleteList(){ // you will need two pointers to delete things from the list
if(List){
entry_t *tempDelete = List;
entry_t *tempHolder = tempDelete->next; // lots of the faults will come from this section of the code
while(tempDelete != 0){
delete tempDelete;
tempDelete = tempHolder;
if(tempHolder)
tempHolder = tempHolder->next;
}
}
}
When you can't get something to compile, it is customary to indicate that is the problem and to provide the errors supplied to you by the compiler. The more specific about the issue you're having, the easier it is to help you.
Your definition of addname requires 4 arguments. You aren't giving it 4 arguments when you call it. Also, when calling a function, arbitrarily placing void in front of it's invocation is not recommended.
Yes i have gotten to the point that i am having segmentation faults now when i try an populate my list. I have been using GDB to try and find my issues but it is just causing me to find more and more errors.
thank you I have already fixed the things from your advice before. When i posted this code i was ready to just quit life. I seem to be making some progress but still have the same issue with getting it to run. I have no compile errors anymore just segmentation faults.