daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Jul 17th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <winsock2.h>
  4.  
  5. #define STDIN 0
  6.  
  7. int main(void)
  8. {
  9.     WSADATA wsaData;
  10.     WSAStartup(MAKEWORD(2,2), &wsaData);
  11.  
  12.     struct timeval tv;
  13.     fd_set readfds;
  14.  
  15.     tv.tv_sec = 5;
  16.     tv.tv_usec = 0;
  17.  
  18.     FD_ZERO(&readfds);
  19.     FD_SET(STDIN, &readfds);
  20.     select(STDIN+1, &readfds, NULL, NULL, NULL);
  21.  
  22.     if (FD_ISSET(STDIN, &readfds))
  23.         printf("input\n");
  24.     else
  25.         printf("timed out\n");
  26.  
  27.     WSACleanup();
  28.     return 0;
  29. }
RAW Paste Data
Top