我有我的代碼的問題,我找不到問題是什麼,因爲我新選擇();
任何人都可以告訴我從哪裏來的問題?C編程錯誤與FD_SET
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();
}
什麼是't_used_piece'? – cnicutar
@cnicutar它是一個先前定義的隨機值的結構。 – Slrs