All pastes #840188 Raw Edit

Unnamed

public c v1 · immutable
#840188 ·published 2007-12-31 15:53 UTC
rendered paste body
#include <stdio.h>#include <stdlib.h>#include <unistd.h>int main(void) {  FILE *fi, *fo;  int pi[2], po[2];  char buf[256];  pipe(pi);  pipe(po);  switch(fork()) {  case -1:    perror("fork");  case 0:    dup2(pi[0], 0);    dup2(po[1], 1);    execlp("tee", "tee", NULL);  default:    fo = fdopen(po[0], "r");    fi = fdopen(pi[1], "w");    fprintf(fi, "hello world");    fscanf(fo, "%s", buf);    fclose(fi);    fclose(fo);  }  fprintf(stdout, "buf = %s", buf);}