+ 2

ring buffer - overwrite function - Correct code link this time.

I am having issues with the overwrite function of the circular buffer file. It keeps returns an empty buffer on some test runs. What am I missing? https://code.sololearn.com/cpBWFOKyi6mL

27th Feb 2022, 2:51 AM
William Owens
William Owens - avatar
4 Réponses
+ 2
I guess by " returns an empty buffer on some test runs" you are referring to the read operation after an overwrite. I reckon, overwrite means to be able to write despite a full buffer. In that case I suppose you need to advance the read head should read == write after the write operation. Otherwise, if you look at your condition in read, read == write will be interpreted as empty buffer. Note, however, only to advance the read head if the write operation actually does overwrite the current read head.
27th Feb 2022, 7:10 AM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Ani Jona I have corrected the issue the code passes all the test put against it now. Thanks for the help.
27th Feb 2022, 2:49 PM
William Owens
William Owens - avatar
+ 1
You're welcome 🙂 What test sets are you testing against? 🤔 That does not look like some competetive programming task 🤔
27th Feb 2022, 2:52 PM
Ani Jona 🕊
Ani Jona 🕊 - avatar
+ 1
Ani Jona: I am learning using Sololearn, Exercism, codewars and books. The test set for this exercise was from: Exercism's Unity test. https://exercism.org/tracks/c/exercises/circular-buffer I'm not competitive just trying to learn on my own. My background is in DOD HR not CS.
27th Feb 2022, 3:14 PM
William Owens
William Owens - avatar