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 8587307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:32:17+00:00 2026-06-11T22:32:17+00:00

I have a function deleteNode that receives the head of the list, and the

  • 0

I have a function deleteNode that receives the head of the list, and the node to be deleted. When I run this, It successfully removes the node, but it also removes everything after it. I believe it has to do with me rebuilding the list, but I can’t figure out where my logic is wrong so I could use a little help. Here is the function code:

void deleteNode(struct lnode** head, struct lnode* node) {
    struct lnode* nextNode = nodeGetNext(node);
    printf("word: \n%s\n",nodeGetWord(nextNode));
    struct lnode* nodeToDelete = node;


    *head = nodeGetNext(nodeToDelete);
    printf("Head word: %s\n",nodeGetWord(*head));
    free(nodeToDelete); 
}
  • 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-06-11T22:32:19+00:00Added an answer on June 11, 2026 at 10:32 pm

    Try drawing it out… I don’t know what your functions do exactly, so this makes some assumptions based on the names, but you can get the idea.

    1. you pass in head (red ‘h’)
    2. you pass in node to delete (blue ‘n’)
    3. you set local nextNode to the return of nodeGetNext(node) (I assume that’s the node after the one to delete, the green ‘nn’)
    4. you set nodeToDelete (purple ntd) to node

    enter image description here

    So your code will point head at nodeGetNext(nodeToDelete). This is actually your unused variable nextNode. Then you free nodeToDelete.

    I’m pretty sure this is not what you wanted to do unless you know that the node to delete is right next to head. I think a more normal algorithm would be:

    1. from head search for node to delete
    2. set “node to delete”-1 next to “node to delete”+1
    3. delete “node to delete”

    With speical cases for the Head, or an empty list, etc.

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

Sidebar

Related Questions

I have function calls that look like this (for no apparent reason): func (
I have function like this: function update_List(){ LIST=[]; $.each(feed_urls,function(index,value){ $.getJSON(value, function(data) { $.each(data.feed.entry,function(i,val){ LIST.push(val.content.src);
I have function which converts a 1D list to a 3D list, but at
I have function like this: function ypg_delete_img($id, $img) { $q = $this->ypg_get_one($id); $imgs =
I have function LoadTempMovieList(), and need to load movies from sessionStorage. But it seems
I have function getCartItems in cart.js and I want to call that function in
I have function Start() that is fired on ready. When I click on .ExampleClick
I have function like this: function gi_insert() { if(!IS_AJAX){ $this->load->library('form_validation'); $this->form_validation->set_rules('name', 'Naslov', 'trim|required|strip_tags'); $this->form_validation->set_rules('body',
Inside my Controller i have function that runs after user clicks on item, which
I have: function doit() { document.getElementById('id1').mozRequestFullScreen(); } But it doesn't work. Though it does

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.