I just started learning C language. Now my task is to write a simple ring buffer.
I wrote a code but it doesn't work. I can't solve the problem, obviously, I indicated wrong parameters in push and pop functions. It's needed to use head, tail and size of the buffer (the problem is in tail i think but can't properly get).

```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct ringBuffer 
{
    void *bufferData;
    int head;
    int tail;
    int size;
    int numElements;
};

void bufferInitialization(struct ringBuffer *buffer, int size) 
{
    buffer->size = size;
    buffer->head = 0;
    buffer->tail = 0;
    buffer->numElements = 0;
    buffer->bufferData = (void*)malloc(sizeof(int)*size);
}

void bufferFree(struct ringBuffer *buffer)
{
    free(buffer->bufferData);
}

int pushBack(struct ringBuffer *buffer, int *data)
{

    /*  int i;
    i = buffer->head + buffer->tail + 1;
    if (i >= buffer->size) 
    {
        i = 0;
    }
    buffer->bufferData[i] = data;*/
    memcpy((void*)buffer->head, data, buffer->size);
    buffer->head = buffer->head + buffer->size;
    if (buffer->head == buffer->tail)
    { 
        buffer->head = (int)buffer->bufferData; //error?
    }
    buffer->numElements++;
    return 0;
}

int popFront(struct ringBuffer *buffer, void *data)
{
    //void * bufferData;

    /*bufferData = buffer->bufferData[buffer->head];
    buffer->head++;
    buffer->tail--;
    if (buffer->head == buffer->size) 
    {
        buffer->head = 0;
    }
    //return bufferData;*/

    memcpy(data, (void*)buffer->tail, buffer->size); //error?
    buffer->tail = buffer->tail + buffer->size;

    if ((void*)buffer->tail == buffer->bufferData)
    { 
        buffer->tail = (int)buffer->bufferData; //error?
    }
    buffer->numElements--;
    return 0;
}

int main() 
{
    struct ringBuffer buffer;
    int size = 5;
    //*buffer->size = 6;
    bufferInitialization(&buffer, size);
    char *data[] = { "1" , "2", "3", "4" , "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20" };

    for (int i = 0; i < size; i++)
    {
        printf("Push: data[%d] = %s\n", i, *data[i]);
        pushBack(&buffer, (int*)data[i]);
    }
    printf("\n");
    for (int i = 0; i < size; i++)
    {
        printf("PushBack: queue[%d] = %s\n", i, (ringBuffer*)popFront(&buffer, (void*)data[i])); // !!!
    }
    printf("\n");

    for (int i = 0; i < size; i++)
    {
        printf("PopFront: data[%d] = %s\n", i, *data[i]);
        pushBack(&buffer, (int*)data[i]);
    }
    printf("\n");
    system("pause");
    return 0;
    }

```

Thanks for any help and advices!