This is the code snippet, it belongs to a bigger project. Basicly it has to store and print how many times a character appears in a block of text. What i dont really seem to understand is how to reallocate the same array....
void subiect2_subpunct_c(char* nume_fisier)
{
    FILE *f1;
    char a;
    int i = 0, j, ok;
    char *caracter, *tempc;
    int *frecventa, *tempf;
    caracter = (char*)malloc(sizeof(char));
    frecventa = (int*)malloc(sizeof(int));
    f1 = fopen(nume_fisier, "r");
    while (a = fgetc(f1))
    {
        ok = 0;
        if (i == 0)
        {
            frecventa[i] = 1;
            caracter[i++] = a;
        }
        else
        {
            for (j = 0; j < i; j++)
            {
                if (caracter[j] == a)
                {
                    frecventa[j]++;
                    j = i;
                    ok = 1;
                }
            }
            if (ok == 0)
            {
                tempc = (char*)realloc(caracter, (i + 1)*sizeof(char));
                tempf = (int*)realloc(frecventa, (i + 1)*sizeof(int));
                caracter = tempc;
                frecventa = tempf;
                frecventa[i] = 1;
                caracter[i++] = a;
            }
        }
    }
    for (j = 0; j < i; j++)
    {
        printf("\n %c (%d)", caracter[j], frecventa[j]);
    }
    fclose(f1);
}
 
     
    