Created
December 16, 2017 05:56
-
-
Save kurahaupo/508e9901617c990ff2b25940c26d4007 to your computer and use it in GitHub Desktop.
sponge.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BUfSIZ*pick a number | |
, add #includes, and ADD ERROR HANDLING */ | |
int main(){ | |
char b[N]="/tmp/.spongeXXXXXX"; | |
char*t=mktemp(b); | |
int f=open(t,O_RDWR|O_CREAT|O_EXCL,0); | |
unlink(t); | |
ssize_t n; | |
while((n=read(0,b,N))>0) | |
write(f,b,n); | |
lseek(f,0,SEEK_SET); | |
while((n=read(f,b,N))>0) | |
writewrite write(1,b,n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment