Working with pointers & queues; syntax problem!

Hey guys, can someone give me a little help with my c++ program I am trying to work on?

Here is the code I was provided: http://pastebin.com/UTfr9BSs

I am supposed to create a little file named queueMain.c and just put the functions provided to use. But for some reason it is giving me an "Arithmetic Exception". What have I done wrong? Right now it is supposed to run queueManage and create a queue called "theQ" with a size of 2. It's then supposed to insert two values into the queue, filling it. Then it is to remove the head value and then run queueManage again to destroy the queue, but for some reason I can't seem to figure out where it is going wrong.


Here is the code I have written. I think I just have some syntax wrong, but for the love of God I can't seem to pinpoint where I have messed up:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    #include <stdio.h>
    #include "queueHeader.h"
     
    int main (int argc, const char * argv[])
    {
     
            QUEUE theQ;
            QUEUE *ptr1 = &theQ;
            QUEUE **ptr2 = &ptr1;
     
            //creating the queue
            queueManage(&ptr1, 1, 2);
            printf("QUEUE of size 2 created");
     
     
            // adding  value to queue
            addToQueue(&theQ, 5);
            printf("Value 5 has been added to the QUEUE");
     
     
            // adding another value to queue
            addToQueue(&theQ, 3);
            printf("Value 3 has been added to the QUEUE");
     
     
            // Remove the front value from queue
            int head = ptr1->head;
            removeFromQueue(&theQ, &head);
            printf("The front value has been removed from the QUEUE");
     
     
            //delete the que
            queueManage(&ptr1, 0, 2);
            printf("QUEUE has been destroyed");
     
            return 0;
    }


Someone please help me quickly! :)
I have only 1 question: Why are you doing C code, and posting it in a C++ forum? Isn't there a C programming forum somewhere in the Internet? I mean, you even say this is C++, and that pastebin says it is C++, but I don't see one letter of C++!!!
Last edited on
Sorry I didn't realize it was that big of a deal. Either way, I have figured out my own error.

Thanks anyways.
It's ok to post C. We look at C issues here too.
Topic archived. No new replies allowed.