fork download
  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5.  
  6. int main(void) {
  7. char s[100];
  8. fd_set fs={0};
  9. printf("Geben Sie innerhalb von 10 Sek. etwas ein: ");
  10. select(1,&fs,0,0,(struct timeval[]){{.tv_sec=10}});
  11. if (FD_ISSET(0, &fs))
  12. scanf("%99[^\n]",s);
  13. else
  14. puts("Timeout");
  15.  
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
Geben Sie innerhalb von 10 Sek. etwas ein: Timeout