Thread: stack and pointer problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    Your error comes from passing a stack ** to CreateEmpty. (You're taking the address of a pointer, &S.) Same goes for the Destruct error. Match your types up.

    Also:
    Code:
    S = &S2;/*(copy stack S2 to stack S)*/
    That doesn't do what the comment alleges it does. That set S (a pointer) to the address of S2. S goes out of scope afterwards, and that statement has no effect.

    Also, "Nil" ? The general rule for #defines is to make them all caps. I'd also use NULL over "Nil" - other programs will read "Nil" and go hunt to find out what Nil is. (Since it's not in caps, it's not obvious it's a define, though one might assume things based on context.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    4

    Still don't know how to solve it

    Thanks cactus_hugger for your reply.

    But i still don't know how to fix the problem. I mean i still dont know how to pass argument to function CreateEmpty and Destruct correctly in this case.

    Could you write the correct code?,so i can understand how to fix it.

    Thank You

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack problem - I've hit a wall!
    By miniwhip in forum C Programming
    Replies: 7
    Last Post: 11-14-2007, 03:05 AM
  2. Stacks
    By Cmuppet in forum C Programming
    Replies: 19
    Last Post: 10-13-2004, 02:32 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  5. more pointer problems
    By dharh in forum C Programming
    Replies: 3
    Last Post: 02-11-2003, 06:52 PM