I am trying to write a funtion to print the contents of a queue using ADT funtions. I composed the following code. It gives me a error of invalid type argument. Need help.

int print_queue(QUEUE *queue)
{
    int tempCount;
    int inputVal;

    while ((queue_count(queue)) != 0)
    {
          tempCount = queue_count(queue);
          queue_front(queue, (void*)&inputVal);
          printf("%d\n", *inputVal);
          dequeue(queue, (void*)&inputVal);
          enqueue(queue, *inputVal);
          tempCount --;
    }

}

Recommended Answers

All 4 Replies

inputVal is not a pointer, yet you try to dereference it like a pointer.

but doesn't void* make it a pointer ?

but doesn't void* make it a pointer ?

Show me where there's a cast to void* here:

printf("%d\n", *inputVal);

And here:

enqueue(queue, *inputVal);

Got your point. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.