Thread: double pointer in struct and queue

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    19

    double pointer in struct and queue

    Here is my situation

    I have a stack that contain's queues. Assume that we have struct queue and struct stack declared. s points to the struct.

    for(i = 0; i < s->top; i++)
    {
    for(x=s->store[i]->front;x<s->store[i]->back;x++)
    {

    printf("%d ", s->store[i]->store[x]);
    }
    }
    Now the problem is that it keeps printing the same thing over and over again it never ends. Like it'l sit there and print the number 9 forever.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Try some simple debugging. Like:
    Code:
    printf("Outer: &#37;d\n",s->top);
    for(i = 0; i < s->top; i++)
    {
        printf("Inner: %d --> %d\n",x=s->store[i]->front, x<s->store[i]->back);
        for(x=s->store[i]->front; x<s->store[i]->back; x++)
        {
           printf("%d ", s->store[i]->store[x]);
        }
    }
    And see what you get and/or post your structs code

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  2. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  3. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 09:09 PM
  4. help with queues
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 05-21-2002, 11:39 AM
  5. queue help
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 10-29-2001, 09:38 AM