int myPipe[2];
int err, child_pid;
err = pipe(&myPipe); //creates the pipe - data written to myPipe[1] can be read from myPipe[0]
child_pid = fork();
if(child_pid == 0)
{
err = dup2(myPipe[1], 1); //set myprogram's standard output to the input of the pipe
execl("/path/to/myprogram", "arg1", "arg2");
}
int pipefd = myPipe[0];
char buffer[255];
err read(pipefd, buffer, 255); // etc etc
// Ideally you would check that err and child_pid != -1