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

#define LIMIT   100ul

typedef struct {
    int     k;
    char    *w;
} pair_t;

int main(void)
{
    const pair_t dictionary[] = {
        {.k = 2, .w = "Fuzz"},
        {.k = 3, .w = "Fizz"},
        {.k = 5, .w = "Buzz"},
        {.k = 7, .w = "Bizz"}
    };
    
    for (size_t n=1; n <= LIMIT; ++n)
    {
        const char *start = "";
        char *output = (char *)start;

        for (size_t e=0; e < sizeof dictionary / sizeof (pair_t); ++e)
            if (n % dictionary[e].k == 0)
            {
                output = realloc(output == start ? NULL : output, strlen(output) + strlen(dictionary[e].w) + 1);
                sprintf(output, "%s%s", output, dictionary[e].w);
            }

        if (strlen(output) == 0)
            printf("%zu\n", n);
        else
        {
            printf("%s\n", output);
            free(output);
            output = NULL;
        }
    }
}
