add write-out

This commit is contained in:
K. Lange 2018-04-17 23:15:20 +09:00 committed by Kevin Lange
parent 592541ef7f
commit a7b41bd6cc

15
apps/write-out.c Normal file
View File

@ -0,0 +1,15 @@
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char * argv[]) {
int fd = open(argv[1], O_WRONLY | O_CREAT);
while (1) {
char buf[1024];
size_t r = read(0, buf, 1024);
if (r == 0) break;
write(fd, buf, r);
}
}