How to use the STACK (push/pop) in C

This is a discussion on How to use the STACK (push/pop) in C within the C Programming forums, part of the General Programming Boards category; Hi all, I'm writing an application that needs using push and pop in C. I don't know how to use ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    45

    How to use the STACK (push/pop) in C

    Hi all, I'm writing an application that needs using push and pop in C.
    I don't know how to use the functions push and pop to put a String and an Int into the stack.

    I know that the stack class only allows char or double, not 2 types just one!

    Thank you in advance for the help!!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    You're extremely confused. I imagine you're actually working with C++ and have no idea how to use the stack class. So try posting some code in the C++ forum and we'll be happy to tell you what you're doing wrong as well as how to fix it.
    My best code is written with the delete key.

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    If you're dealing with classes, then you're doing this with C++.

    A stack is just an abstract data type, where whatever you put into it last, comes out of it first. From what it sounds like, your assignment is to write your own implementation of a stack, or to use an existing one (perhaps via C++'s STL stack?).

    In case you need to read up on the details of a stack: http://en.wikipedia.org/wiki/Stack_(data_structure)

    If this post isn't helpful, then you need to supply more information as to what your problem is.

    Edit: Getting only slower as time goes on. :'(

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    45
    You're extremely confused.
    No man, my keyboard isn't so fast as my fingers

    I imagine you're actually working with C++ and have no idea how to use the stack class.
    No code...cause there's no code :P
    I have only a 'string' (containing the word) and an 'int' (containg the position of the word in a txt file).

    I don't know how many of that words I could have in the text, so I use the stack to push and pop the position and the string!

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-12-2006, 12:41 AM
  2. infix evaluation using stack
    By lewissi in forum C++ Programming
    Replies: 0
    Last Post: 11-03-2005, 02:56 AM
  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, 06:36 PM

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