Skip to content

Commit

Permalink
add stdin_printer test
Browse files Browse the repository at this point in the history
  • Loading branch information
rofl0r committed Feb 16, 2017
1 parent 1de23bb commit af744d7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/stdin_printer.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* like cat, but processing one line at a time. stdin only. */
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main() {
char buf[1024];
while(fgets(buf, sizeof buf, stdin)) {
ssize_t l = strlen(buf);
ssize_t n = write(1, buf, l);
if(n != l) {
perror("write");
return 1;
}
}
return 0;
}

0 comments on commit af744d7

Please sign in to comment.