You are implementing a circular buffer using a C struct.
The buffer is defined as:
typedef struct {
int buffer[100]; // Fixed memory for data
int head; // Write index
int tail; // Read index (not used here)
int count; // Number of elements in buffer
int capacity; // Maximum number of elements buffer can hold
} CircularBuffer;
Implement the function:
void insert_circular(CircularBuffer *cb, int value);
This function should:
Insert the value at the current head index in the buffer
Advance head with wrap-around using modulo
Increment count after insertion
If buffer is full (count == capacity), do not insert anything
Constraints
1 ≤ n ≤ 100
Insert up to k values (input)
You do not need to manage the reading logic in this problem