#include <stdio.h> int main(void) { char string[512]; fgets(string ,512,stdin); puts(string); return 0; }
--------------------------------------------------------------
example:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> int main(void) { int len ; int apipe[2] ; int i ; char buf[256] ; if (pipe(apipe) == -1) { perror("can not create a pipe/n") ; exit(1) ; } while (fgets(buf , 256 , stdin)) { len = strlen(buf) ; if (write(apipe[1] , buf , len) != len) { perror("writing to pipe") ; break ; } for (i = 0 ; i < len ; i++) buf[i] = '/0' ; len = read(apipe[0] , buf , 256) ; if (len == -1) { perror("reading form pipe") ; break ; } if (write(1 , buf , len) != len) { perror("writing to stdout") ; exit(1) ; } } return 0 ; }