Thread: C programming

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

    Question C programming

    hi friends

    i am stuck in a stack program .

    in my program pop operation is not working properly.

    it removes top element first time but second time it shows error. perhaps free is not working.

    i am attaching my program. any help would be appreciated.


    new user

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > struct stack *pop (struct stack * tos);

    This should be declared as
    int pop (struct stack * tos);

    You want to return the top element from the stack.

    You need to think about how to return a modified stack from this function.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed