while(scanf("%d", &num) != EOF)
{
}
或者
while(scanf("%d", &buf[buf_len++]) == 1);
while
(scanf(
"%d"
, &buf[buf_len++]) ==
1
);