Pseudo-object orientation in C and dynamic allocation

I am trying to make a minefield in c using ncurses.h and when I go to make the vector of "bomb objects" Linux says it can't find the memory space in which the values of the bombs are:

PS: no I can't use C++

typedef struct Bomb
{
    int x, y;
} Bomb;

Bomb* setBomb(int i){

    Bomb* newBomb = malloc(sizeof(Bomb));

    srand(time(NULL) / i);
    newBomb->x = rand() % i * (i + 1);

    srand(time(NULL) * i);
    newBomb->y =  rand() % i * (i + 1);

    return newBomb;
}

Bomb** setBombs(WINDOW* win, int amountBombs)
{

    Bomb** bombs = malloc(sizeof(Bomb) * amountBombs);

    for(int i = 0; i < amountBombs; ++i)
    {
        bombs[i] = setBomb(i);
    }

    drawBomb(win, bombs, amountBombs);

    return bombs;
}

int drawBomb(WINDOW* win, Bomb** bomb, int amount)
{

    for (int i = 0; i < amount; i++)
    {
        mvwprintw(win, bomb[0]->y, bomb[0]->x, "O");
    }
}
Author: Daniel Mendes, 2020-03-17

1 answers

I fixed the error: the problem was in srand (), I was doing with q it generated a floating point number and this n is allowed

 0
Author: Cauê, 2020-03-17 19:07:05