I am really stuck...please help
If i have a file queue.c that contains:
and queue.h that is a header file with some declared vars and:Code:int init_queue(Queue *q, int max_chars); make a new empty queue, filling in *q int enqueue(Queue *q,char ch); enqueue char ch on q, or return -1 if can't int dequeue(Queue *q); dequeue a char and return it, or return -1 if can't int queuecount(Queue *q); return # chars currently in queue q
How can i make my own QUEUE struct in another program?Code:typedef struct queue { char ch[MAXCHARBUF]; /* char contain in queue */ int front; /* front index of queue */ int rear; /* rear index of queue */ int count; /* current numbers of element in queue */ int max; /* actually use length */ } Queue;
For instance, I am working on tty.c program that uses interupts and has a buffer that stores chars from the user, but I want to change these buffers in my "read" and "write" parts of tty.c to use Queues instead.
I have also been told that I may have to use two structs, where one uses points to the other, in order to invoke this, but I am already lost so I think just setting up a Queue struct will be a good start.



LinkBack URL
About LinkBacks


