vendredi 8 mai 2015

Pointer value in Mac OS - Get Value from queue

I've defined a struct like this:

typedef struct queue
{
    int front, count;
    int values[MAX];
}QUEUE;

And when i try to get the value in the front of the queue (passing it to a variable) i get an error: "illegal instruction:4"

The function getting the value is:

int front(QUEUE *q, int *x){
    int r=0;

    if(q->count==0) r=1;
    else{
        *x = q->values[q->front];
    }
}

In fact , this compiles at a linux environment.

What could be the cause of the problem?

PS.: I've had it run with sudo. It does not show the error, but doesn't output anything .

Thank you all for your help in advance.

Aucun commentaire:

Enregistrer un commentaire