#include <stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<unistd.h>
#include
<fcntl.h>
#include
<sys/select.h>

int main(int argc,char *argv[])
{

char buf[100] = "";
fd_set rset;
//select集合
FD_ZERO(&rset); //将集合清0
FD_SET(0, &rset); //将标准输入加入到集合中

while(1)
{
#if 0
if(select(1, &rset, NULL, NULL, NULL)>0)
{
printf(
"please input:");
fflush(stdout);
read(
0, buf, 100);
printf(
"buf=%s\n",buf);
}

#else
printf(
"please input:");
fflush(stdout);
read(
0, buf, 100);
printf(
"buf=%s\n",buf);

#endif
}
return 0;
}

  

相关文章:

  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-04
  • 2021-06-14
  • 2021-06-21
  • 2022-12-23
相关资源
相似解决方案