Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't delete the node from the end of a linked list
    primarykey
    data
    text
    <p>I have a problem about deleting the last node of my linked list. I put printf functions to check and locate the error but I can't find it. This my code for deleting the last node from an unsorted linked list. At the end you will see four add functions and they are working successfully. The only broken part is deleting from the end. </p> <pre><code>void del_Node(LIST* list, int counter) { if( counter == 0 ) return; NODE* temp = list-&gt;header; int count=1; if( list-&gt;header == NULL ) { printf("The list is already EMPTY\n"); return; } while( count != counter ) { temp = temp-&gt;next; count++; } printf("%s %s\n", temp-&gt;first_name, temp-&gt;last_name); if( list-&gt;counter == 1 ) { // Condition for deleting the last node of the linked list list-&gt;header = NULL; list-&gt;tail = NULL; temp-&gt;next = NULL; temp-&gt;pre = NULL; list-&gt;counter--; } else if( list-&gt;header == temp ) { // Condition for deleting from the beginnig list-&gt;header = temp-&gt;next; printf("%s listenin basından silindi\n", temp-&gt;first_name); temp-&gt;next = NULL; temp-&gt;pre = NULL; list-&gt;counter--; } else if ( list-&gt;tail == temp ) { // Condition for deleting from the end list-&gt;tail = temp-&gt;pre; printf("%s normal listenin tailinden silindi yeni tail %s\n", temp-&gt;first_name, temp-&gt;pre-&gt;first_name); temp-&gt;next = NULL; temp-&gt;pre = NULL; list-&gt;counter--; } else { // Condition from deleting from the middle temp-&gt;pre-&gt;next = temp-&gt;next; temp-&gt;next-&gt;pre = temp-&gt;pre; printf("%s normal listede %s------%s arasından silindi\n",temp-&gt;first_name, temp-&gt;next-&gt;first_name, temp-&gt;pre-&gt;first_name); temp-&gt;next = NULL; temp-&gt;pre = NULL; list-&gt;counter--; } del_fn_name(list, temp); del_ln_name(list, temp); del_bdt(list, temp); del_city(list, temp); free(temp); printf("List-&gt;counter = %d %d %d\n", list-&gt;counter, list-&gt;fn_count, list-&gt;ln_count ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload