Thread: Creating a stack

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    155

    Creating a stack

    I am supposed to make a program that allows one to type a string of letters and then output them in reverse. You simply put each letter into the stack then pull them back out in reverse. However, I do not know how to make a stack >.< It isn't in the book and it's driving me mad. It's supposed to be linklist-related, and it has a "push, pop", and "onTop" function. Heelllp!

    The only example they give:

    Code:
    EXAMPLE OF A STACK:
    
    stack<int> s;
    s.push(4);
    s.push(10);
    s.push(12);
    item = s.pop();
    s.push(3 * item);
    item = s.onTop();
    s.push(3 * item);

  2. #2
    CS Author and Instructor
    Join Date
    Sep 2002
    Posts
    511

    Cool

    This question has been answered before. Go to a seach engine and look it up!
    Mr. C: Author and Instructor

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    Posts
    1,683
    well i have implemented one in C++ (classes..) want to have a look..

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    155
    Yes, please

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    This question has been answered before, and I've posted a full (naive) implementation at least once or twice.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Profiler Valgrind
    By afflictedd2 in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2008, 09:38 AM
  2. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM