Thread: Stacks stacks stacks

  1. #1
    Unregistered
    Guest

    Question Stacks stacks stacks

    How do you set the stack input amount? like for example, I only want the stack to hold 10 data and no more. Is therre a way to do this?

  2. #2
    Registered User Zeeshan's Avatar
    Join Date
    Oct 2001
    Location
    London, United Kingdom
    Posts
    226
    It depends upon how you're implementing the stacks.

    You could be using linked-lists, arrays...or even some ready-made stack system provided by your compiler...

    plz mention these details, so you can get a reasonable answer.

  3. #3
    Unregistered
    Guest
    oops...
    Its using a singly linked list.

  4. #4
    Unregistered
    Guest

    example please

    does anybody has an example for linked list?

  5. #5
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Store your stack in something like

    typedef struct Node {
    int data;
    struct Node* next;
    } Node;

    typedef struct Stack {
    Node* header;
    int n;
    } Stack;

    When you create a stack set n to 0 and then
    Everytime you insert increment n and compare n to 10.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please Help Me With This Code Of Implementing Stacks
    By raghu_equinox in forum C Programming
    Replies: 3
    Last Post: 10-19-2006, 07:22 AM
  2. ...multiplication using stacks
    By iiwhitexb0iii in forum C Programming
    Replies: 1
    Last Post: 10-09-2006, 01:28 AM
  3. Stacks
    By Pressure in forum C Programming
    Replies: 9
    Last Post: 02-27-2005, 02:10 PM
  4. Avioding Stacks
    By LoafOfBread34 in forum C++ Programming
    Replies: 8
    Last Post: 12-08-2004, 06:20 AM
  5. Dumping singly linked list into 2 stacks.
    By strotee76 in forum C++ Programming
    Replies: 5
    Last Post: 05-16-2004, 05:48 PM