![]() Redis 7.2 includes optimizations, several new commands, some improvements, bug fixes, and several new module APIs. Multiple versions are available, usually updated shortly after each new release. If you're trying to return a success value, void * likely isn't the right way of doing this.You can download and run Redis Docker images from DockerHub. Also, your addRecord had return type void *, and you return EXIT_SUCCESS. You shouldn't cast the return value of malloc in C. ![]() There are a couple additional things I changed. Avoiding this double pointer could be done like you've done in your edited question, but modified to go through the list's nexts: //Add new node to the end of the listīoth cases require that the initial list->head is NULL, but it seems like that's already the case, given your printing. This allows the head in List and next in Node to be represented in the same way.Īnother way of doing it is slightly less elegant, but more readable. The way I chose here uses a pointer to a Node *. There are many ways of adding to the tail of the list. One way to fix this is to change your addRecord function: static void addRecord(List *list, int newID, char *newName, char *newSummary, int newCount) You always add at the head instead of the tail of your list. The issue is in the way you add to your list. I am having trouble understanding the segmentation fault error that occurred, could someone please explain it to me? However, now, I get the following error: Segmentation fault: 11 Special case: If the first node is null, add the data here I have tried other ways to add the record in, but I keep getting Segmentation Fault: 11 when I try to do so.Īfter Thomas Jager's comment below, I made the following modification to my addRecord method: static void *addRecord(List *list, int newID, char *newName, char *newSummary, int newCount) Could someone explain to my why my list is printing backwards? I am trying to trace it, but I am kind of confused. ![]() In my print method, when I try to print the contents of the head node, I get the data/information from the item with ID 7, when I should get the information for the item with ID 1. However, my actual output is: LIST IN FORWARD ORDER: Summary: For mistakes made when writting with ink Summary: Gel pens with red ink for grading My expected output should look like this: LIST IN FORWARD ORDER: ** Pointer to the first node on the list (or NULL ). ** Structure for the whole list, including head and tail pointers. Here is how my linked list is set up: //struct for each office item ![]() ![]() Create a temporary node to traverse the list Node *new = (Node *)malloc(sizeof(Node)) I also have a method to print the contents of the linked list, all shown below: static void *addRecord(List *list, int newID, char *newName, char *newSummary, int newCount) I have tried to write an addRecord method (shown below) in which I allocate memory for a new node, assign in the data it requires, and attempt to add it add the end of the linked list. I am having issues with printing my linked list. Thus far in my program, my input is being read in correctly, and I have debugged that portion, so I know that is not the issue. I would like to print the contents of my linked list, which come from a file, as follows: 1,Postit Notes,Sticky notes,3Ĥ, Red pens, Gel pens with red ink for grading, 3ħ,Whiteout,For mistakes made when writting with ink,3 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |