dlong@sdsu.UUCP (Dean Long) (03/08/87)
This is another diff for head.c. This one uses putc() instead of prints(), so you don't have to worry about having a buffer, and lines can be as long as you want. Please try it, and report any bugs you find. (Apply diff to original commands/head.c). -------------------------------------------------------------------- 1a2 > /* change to use putc() instead of prints() -- Dean Long 3/7/87 */ 2a4 > 8d9 < char lbuf[256]; 57,59c58 < /* Print the first 'n' lines of a file. */ < while (n--) do_line(); < } --- > int c; 61,71c60,69 < < do_line() < { < /* Print one line. */ < < char c, *cp; < cp = lbuf; < while ( (c = getc(stdin)) != '\n') *cp++ = c; < *cp++ = '\n'; < *cp++ = 0; < prints("%s",lbuf); --- > /* Print the first 'n' lines of a file. */ > while(n) > switch (c = getc(stdin)) { > case EOF : > return; > case '\n': > --n; > default : > putc((char)c, stdout); > }