The given code produces a Floating point exception ,Can anyone tell me what this caused by?
int play(t_env* env, t_pos* pos)
{
pid_t pid;
int ret;
t_data data;
int status;
pos->addx = 1;
pos->addy = 0;
pos->x = 2 + rand() % data.row;
pos->y = 2 + rand() % data.col;
pid = getpid();
ret = waitpid(WAIT_ANY, &status, WNOHANG);
if (ret == -1)
{
id_print_str("Error during waiting stat");
exit(1);
}
while (pos->x != data.row)
{
tputs(tgoto(env->cm, pos->x, pos->y), 1, id_put);
id_print_char('1');
sleep(1);
pos->x = pos->x + pos->addx;
pos->y = pos->y + pos->addy;
return (0);
}
As per the given code,I suppose, Its only possible here,
make sure that
data.rowanddata.colare non-zero. Or else, the problem might be somewhere else.