ref: 91fc7321c2b7df934036f7b88ffdd5d6c826e941
dir: /ex/ex1-17.c/
#include <u.h> #include <libc.h> #include <bio.h> const MIN = 80; /* Print lines greater than 80 runes. */ void main(int, char*[]) { Biobuf *in, *out; in = Bfdopen(0, OREAD); out = Bfdopen(1, OWRITE); u32int len = 0; while(1){ char *line; int len, n; // Read line = Brdline(in, '\n'); len = Blinelen(in); if(line == 0) break; if(len < 0) sysfatal("err: could not read line → %r\n"); if(len <= 80) continue; // Write n = Bwrite(out, line, len); if(n < 0) sysfatal("err: could not write rune → %r\n"); } Bterm(in); Bterm(out); exits(nil); }