zerotrunc.c 300 B

1234567891011121314151617181920212223
  1. /*
  2. * cat standard input until you get a zero byte
  3. */
  4. #include <u.h>
  5. #include <libc.h>
  6. #include <bio.h>
  7. void
  8. main(void)
  9. {
  10. int c;
  11. Biobuf bin, bout;
  12. Binit(&bin, 0, OREAD);
  13. Binit(&bout, 1, OWRITE);
  14. while((c = Bgetc(&bin)) != Beof && c != 0){
  15. Bputc(&bout, c);
  16. }
  17. Bflush(&bout);
  18. exits(0);
  19. }