Content deleted Content added
m Undid edits by 2407:C00:6004:3D05:6CA6:2BF8:78ED:B522 (talk) to last revision by BrownHairedGirl |
HughesMann (talk | contribs) m improved style in the code example, changed a useless comment and corrected a constant definition. The entire section and the code example remains incorrect and misleading and I shall fix it fully if I find the time |
||
Line 68:
<syntaxhighlight lang="c">
#define BUFLEN 3
int buf[N]; // N elements circular buffer▼
int end = 0; // write index▼
int start = 0; // read index▼
void put(int item) {▼
buf[end++] = item;▼
end %= N;▼
{
▲ buf[end++] = item;
▲ end %= N;
}
int get()
{ int item = buf[start++];
start %= N;
return item;
}
</syntaxhighlight>
|