70,024
社区成员




#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
int main()
{
fd_set rset;
struct timeval tv;
tv.tv_sec = 2;
tv.tv_usec = 0;
FD_ZERO(&rset);
FD_SET(0, &rset);
int b = select(1, &rset, NULL, NULL, &tv);
if( b == 0 )
{
printf("no input in 2 secs\n");
return 0;
}
char buf[128];
fgets(buf, 100, stdin);
printf("buf=[%s]\n", buf);
return 0;
}
#include <stdio.h>
int main(void)
{
while(1) {
char str[100]="";
int res=scanf("%s",str);
if(res!=0)
system(str);//你想执行的命令
}
return 0;
}