diff options
| author | Miguel <m.i@gmx.at> | 2018-09-21 01:43:25 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-21 01:43:25 +0200 |
| commit | ace0646608c393d8952b14536090c302bed2ee85 (patch) | |
| tree | 5d96e0d0a66c27818b677af3a84ef52af0260be1 /userspace/grep.c | |
| parent | aeefdb37d1fc1c0eb7953b9c196cab09460bc167 (diff) | |
piperei working finally :)
Diffstat (limited to 'userspace/grep.c')
| -rw-r--r-- | userspace/grep.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/userspace/grep.c b/userspace/grep.c index c37392f..68d5b7a 100644 --- a/userspace/grep.c +++ b/userspace/grep.c @@ -3,15 +3,17 @@ int main(int argc, char **argv) { - while(1) - { - char buf[256]; - int l=fread(buf,1,255,stdin); - if(l==0)break; - buf[l]=0; - printf("grep: %s",buf); + FILE *in=stdin; + FILE *out=stdout; - } + while(1) + { + char buf[2]; + int l=fread(buf,1,1,in); + if(l==0)break; + buf[l]=0; + fwrite(buf,1,l,out); + } - return EXIT_SUCCESS; + return EXIT_SUCCESS; } |
