У меня проблема с моим кодом, и я не могу выяснить, в чем проблема, поскольку я новичок в select ();
Может кто-нибудь сказать мне, в чем проблема?
run_fct.c: In function ‘run’:
run_fct.c:22: error: invalid type argument of ‘->’ (have ‘fd_set’)
cc1: warnings being treated as errors
run_fct.c:11: error: unused variable ‘timeout’
make: *** [run_fct.o] Error 1
FD_SET(0, fds);
void run(t_coord* piece, t_env* env, t_used_piece* rand_piece)
{
char arrows[2000];
int number;
int nread;
int ret;
fd_set fds;
struct timeval timeout;
int test;
test = 0;
(void)env;
number = 0;
set_keypress();
init_pieces(piece);
while (1)
{
FD_ZERO(&fds);
FD_SET(0, fds);
ret = select(1, &fds, 0, 0, 0);
if (test == 0)
{
get_piece(rand_piece);
number = rand_piece->piece;
print_piece(env, piece, number);
}
if (ret > 0)
{
if (FD_ISSET(0, &fds))
{
nread = read(0, arrows, 3);
if (arrows[0] == 27 && arrows[1] == '[' && arrows[2] == 'A')
{
printf("A = UP\n");
piece[number].ay = piece[number].ay + 1;
}
else if (arrows[0] == 27 && arrows[1] == '[' && arrows[2] == 'B')
{
piece[number].ay = piece[number].ay + 2;
}
else if (arrows[0] == 27 && arrows[1] == '[' && arrows[2] == 'C')
{
piece[number].ax = piece[number].ax + 1;
piece[number].ay = piece[number].ay + 1;
}
else if (arrows[0] == 27 && arrows[1] == '[' && arrows[2] == 'D')
{
piece[number].ax = piece[number].ax - 1;
piece[number].ay = piece[number].ay + 1;
}
else
{
piece[number].ay = piece[number].ay + 1;
}
}
}
test = 1;
}
reset_keypress();
}