c stack

This is a discussion on c stack within the C Programming forums, part of the General Programming Boards category; Could someone help me write a short program to determine the value at the bottom entry in a stack w/o ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    9

    Unhappy c stack

    Could someone help me write a short program to determine the value at the bottom entry in a stack w/o changing the stack?

    Thanks, I'm a bit over my head in an algorithms course.
    This stack has a seperate interface and an implementation file with the code for the push, pop, init, and empty functions.

    Heres what I have as an idea?

    int STACKvalue (int value)
    int i, N = 0;
    Item x[value];
    while (!STACKempty)
    {
    x[N] = STACKpop();
    N++;
    }

  2. #2
    Banned borko_b's Avatar
    Join Date
    Jun 2002
    Location
    Well... I live in Bulgaria :)
    Posts
    100
    hmm..


    And what kind of stack do you refer to?
    i mean .. is this the stack that the exe file is allocating ?

    or it is some data structure you made in some program?

    if it is the second, post your stack data structure implementation here, so anyone could know what you're talking about...

  3. #3
    Unregistered
    Guest
    First of all, which implementation of a stack are you using? If it's an array implementation, then just reference the index where your first item is.

    If it's not an array (i.e. linked list or something), use what Salem suggested and just keep popping from the current stack and placing the results on another stack. Then the top value on the new stack is the bottom value from the stack that you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. infix evaluation using stack
    By lewissi in forum C++ Programming
    Replies: 0
    Last Post: 11-03-2005, 01:56 AM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 09:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 05:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21