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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:26:05+00:00 2026-05-27T21:26:05+00:00

I have a list with a few nodes. I’m trying to mark the final

  • 0

I have a list with a few nodes. I’m trying to mark the final node by declaring it’s current->next value as NULL.

So, let’s say that my current is pointing at the final node. Do the two following code snippets work in a different way, and if yes, how?

 current->next = NULL;

and

 current = current->next;
 current = NULL;

I have been experimenting with these for a while now but I cannot really understand what is going on in there. I would say they are doing the same thing, as the second one first points my current to where next points and then sets it to NULL.

EDIT : Oh, I understand what the answers are saying, and it looks quite obvious to me too now :). So if I do not use the first way, but opt to go for current = current->next is there a way for me to put the NULL value where I ought to? How can I use my new current to point where my old next was pointing at?

  • 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-27T21:26:05+00:00Added an answer on May 27, 2026 at 9:26 pm

    The former snippet assigns the next field of the struct pointed to by current to NULL. The second snippet makes the current pointer point at the next field of the struct pointed to by current and then sets current to NULL.

    I don’t really understand the usefulness of the second unless you have some other way to get a reference to the struct, since you essentially cut yourself off from the struct by losing your pointer to it.

    So in the former case:

    current -> struct
               next -> NULL
    

    In the latter case:

    current -> NULL
    
               struct
               next -> ????
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a tree of nodes like this: class Node: next # the next
I have a few list elements, like this: <li class=item> <a class=toggle><h4>ämne<small>2010-04-17 kl 12:54
I have an unordered list with a few list elements. #tags { width: 300px;
I'm just starting with programming. I have a list of a few strings and
I have a List of a complex type - an object with a few
I have a few, possibly trivial, questions with using forever with Node.js. From what
I have a code of doubly Linked list and there are few lines of
I have a form with a list box and a few text boxes, when
Let's imagine I have a collection of nodes that I use for my Renderer
I'm stuck trying to figure how to do the following: I have a few

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.