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.)
Jump to Post
One 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 …
Answered by iamthwee 1,547 in a post from
Jump to Post
The implementation of queue is much more difficult than a stack, especially in c.
Have you tried googling for
. It should return more than enough examples.
All 7 Replies
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Dani 3,632 The Queen of DaniWeb Administrator Featured Poster Premium Member
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.