+ 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
4 Answers
+ 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.
+ 1
Ani Jona I have corrected the issue the code passes all the test put against it now. Thanks for the help.
+ 1
You're welcome š What test sets are you testing against? š¤ That does not look like some competetive programming task š¤
+ 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.