Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Pick your poison

Name: Anonymous 2011-06-24 5:46


 switch(fd)
 {
  case 0:
   f = freopen(_PATH_DEVNULL, r, stdin);
  break;
  case 1:
   f = freopen(_PATH_DEVNULL, w, stdout);
  break;
  case 2:
   f = freopen(_PATH_DEVNULL, w, stderr);
  break;
  default:
   f = NULL;
  break; 
 }



 f = (fd == 0) ? freopen(_PATH_DEVNULL, r, stdin)
               : (fd == 1) ? freopen(_PATH_DEVNULL, w, stdout)
                           : (fd == 2) ? freopen(_PATH_DEVNULL, w, stderr)
                                       : NULL;

Name: Anonymous 2011-06-24 6:22

typedef struct {
char* mode;
FILE* stream;
} write_out;

write_out methods[3] = {
   { "r", stdin },
   { "w", stdout },
   { "w", stderr }
};

freopen(_PATH_DEVNULL, methods[fd].mode, methods[fd].stream);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List