Thread: Stack and Multiple Queues Syntax

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    8

    Stack and Multiple Queues Syntax

    Hey guys, I'm working on a program for my computer science class that is based on stacks and queues. Without going into too much detail of what the program is actually supposed to do (I think I understand the algorithm without issues), I just need some help on syntax for functions involving stacks and queues. The professor strongly suggested an array based stack and linked list based queues.


    Basically I need to read data in and enqueue it into the first queue. Then I dequeue from there and enqueue into another queue. Our class basically has the functions posted for us.

    int enqueue(struct queue* qPtr, int val);

    This is where I'm unsure of how to change it. I think I'm supposed to do something like this when I call the function:

    int enqueue(struct queue* qPtr, dequeue(struct queue2* qPtr));

    Now, what I would like to know is if this is correct, do I need to call the dequeue function before the enqueue function or is calling the enqueue actually called dequeue as well?

    Thanks so much for any help!

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by NICKD54
    This is where I'm unsure of how to change it. I think I'm supposed to do something like this when I call the function:

    int enqueue(struct queue* qPtr, dequeue(struct queue2* qPtr));
    Unfortunately, no. Recall the difference between declaring a function and calling it.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stack and Queues questions
    By ee1215 in forum C++ Programming
    Replies: 12
    Last Post: 03-29-2011, 07:19 PM
  2. Replies: 2
    Last Post: 04-02-2010, 06:04 AM
  3. Replies: 1
    Last Post: 05-04-2009, 07:54 PM
  4. Multiple syntax errors
    By Devolution in forum C Programming
    Replies: 1
    Last Post: 03-25-2009, 10:37 PM
  5. Queues/Stack exercises
    By sureshhewa in forum C Programming
    Replies: 4
    Last Post: 08-02-2008, 01:45 AM