Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620458
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:33:48+00:00 2026-05-22T02:33:48+00:00

I have a problem about deleting the last node of my linked list. I

  • 0

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.

void del_Node(LIST* list, int counter) {

    if( counter == 0 )
        return;

    NODE* temp = list->header;

    int count=1;

    if( list->header == NULL ) {
        printf("The list is already EMPTY\n");
        return;
    }

    while( count != counter ) {
        temp = temp->next;
        count++;
    }

    printf("%s %s\n", temp->first_name, temp->last_name);

    if( list->counter == 1 ) { // Condition for deleting the last node of the linked list

        list->header = NULL;
        list->tail = NULL;

        temp->next = NULL;
        temp->pre = NULL;

        list->counter--;

    }

    else if( list->header == temp ) { // Condition for deleting from the beginnig

        list->header = temp->next;

        printf("%s listenin basından silindi\n", temp->first_name);

        temp->next = NULL;
        temp->pre = NULL;

        list->counter--;

    }

    else if ( list->tail == temp ) { // Condition for deleting from the end

        list->tail = temp->pre;

        printf("%s normal listenin tailinden silindi yeni tail %s\n", temp->first_name, temp->pre->first_name);

        temp->next = NULL;
        temp->pre = NULL;

        list->counter--;

    }

    else { // Condition from deleting from the middle

        temp->pre->next = temp->next;

        temp->next->pre = temp->pre;

        printf("%s normal listede %s------%s arasından silindi\n",temp->first_name, temp->next->first_name, temp->pre->first_name);

        temp->next = NULL;
        temp->pre = NULL;

        list->counter--;

    }

    del_fn_name(list, temp);
    del_ln_name(list, temp);
    del_bdt(list, temp);
    del_city(list, temp);

    free(temp);

    printf("List->counter = %d %d %d\n", list->counter, list->fn_count, list->ln_count );
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:33:48+00:00Added an answer on May 22, 2026 at 2:33 am

    it seems you forgot temp->pre->next = NULL;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem adding arraylist to list view, will explain about my problem here..
I have a problem about session variables. Session variables is deleting random time in
I have read about this error, but none of the answers seem to apply
I have a problem about div position relative alignment. I want the second div
I am using MFC CFile Seek function. I have a problem about Seek out
I have a little problem about using jQuery (I really do not know jQuery
I have hit upon this problem about whether to use bignums in my language
I have got a strange problem about in_array recently which I cannot understand. e.g.
I have got a performance problem about TextField.htmlText +=msg .And I know that TextField.appendText(msg)
I'm having problem about web service method with auto increment ID. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.