Advertisement
JPeterson

readm.cpp

Oct 11th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. // (C) John Peterson. License GNU GPL 3.
  2. // Binary stdin/stdout pass-through.
  3. #include <iostream>
  4. #include <stdint.h>
  5. #include <sys/stat.h>
  6. typedef uint8_t u8;
  7. typedef uint32_t u32;
  8. int main(int argc, char **argv) {
  9.     const u32 len = 0x2000;
  10.     u8 buf[len];
  11.     u32 size;
  12.     freopen(NULL, "rb", stdin);
  13.     freopen(NULL, "wb", stdout);
  14.     while (true) {
  15.         size = read(STDIN_FILENO, buf, len);
  16.         if (size == 0) break;
  17.         write(STDOUT_FILENO, buf, size);
  18.     }
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement