Any idea how to implement a FIFO queue of chars in C? It doesn't need to be too fancy, just a fixed size (say 256 chars) and can't use any library functions (this is for a hobby OS kernel I'm writing, and there's not a lot of functions available for use). I just tried to make one, then I realized... hey wait, this is an implementation of a stack, not a queue :p (I must say, it worked pretty well for a stack... but I don't need a stack here.)
mmiikkee12
1
Posting Whiz in Training
Recommended Answers
Jump to PostOne array and two indecies. One index points to the empty position for the next character to be added. Other index points at the character to be removed when needed. When either getst to the end of the array, reset to beginning.
You need to decide when the queue …
Jump to PostThe implementation of queue is much more difficult than a stack, especially in c.
Have you tried googling for
queue.c
. It should return more than enough examples.
All 7 Replies
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
iamthwee
mmiikkee12
1
Posting Whiz in Training
Dani
4,084
The Queen of DaniWeb
Administrator
Featured Poster
Premium Member
mmiikkee12
1
Posting Whiz in Training
mmiikkee12
1
Posting Whiz in Training
kiranxxx
0
Newbie Poster
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.