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

  • Home
  • SEARCH
  • 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 624657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:13:27+00:00 2026-05-13T19:13:27+00:00

I am just wanting a simple explanation of the linking process when pushing data

  • 0

I am just wanting a simple explanation of the linking process when pushing data onto a stack. I know how to build on using the code from my book, but I am not really sure I understand how the process works when you move the stack head link from one to the next.

For stacks like:

typedef struct node
{
    void dataptr;
    struct node* link;
}STRUCT_NODE;

typedef struct
{
    int count;
    STACK_NODE* top;
}STACK;

How do you change the link to point to the new data pushed on the stack. Also I do not know

  • 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-13T19:13:27+00:00Added an answer on May 13, 2026 at 7:13 pm

    Stacks can be implemented in various ways, but given the way you phrase your question I’m assuming your stack is just a linked list, something like

    head
    ↓
    A → B → C → D → 0
    

    “when you move the stack head link from one to the next” the picture just changes to:

        head
        ↓
    A → B → C → D → 0
    

    Of course A is not reachable any more in this graph, so you’d better have another pointer to it somewhere (be it only to dispose of it), but this is the gist how how the stack is popped (by making head = head->next if each node in the stack is a struct node with a next field that’s a struct node*, and of course head is a struct node* as well).

    That’s for popping something off the stack (and you should free the memory used by A in that case). In detailed steps, it would be:

    1/ Saving the old head.

          head
          ↓
    old → A → B → C → D → 0
    

    2/ Adjusting the head.

              head
              ↓
    old → A → B → C → D → 0
    

    3/ Returning the old head (pointed at by old).

    If instead you’re talking about pushing something onto the stack, that’s an operation that involves:

    1/ Creating a new element.

        head
        ↓
    Z   A → B → C → D → 0
    

    2/ Pointing it towards the current head

        head
        ↓
    Z → A → B → C → D → 0
    

    3/ Adjusting the head to point to it.

    head
    ↓
    Z → A → B → C → D → 0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on (what should be) a simple project, taking the input from stdin and
Quite often, I find myself wanting a simple, dump object in Python which behaves
I am wanting to show a simple loading dialog when certain things are happening
I'm moving away from strict Android development and wanting to create iPhone applications. My
I'm building a simple notes site using Sinatra and Heroku. I write my notes
I am wanting to know if it's possible to instantiate a null object inside
I am working on a piece of code that I am wanting to spice
This is just a general question - I was sitting and waiting for a
Just what the title says, I need to change the password for an existing
Just looking for the first step basic solution here that keeps the honest people

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.