Using Redhat 9, what is the best way to do it?

Roughly speaking, I got this to work:
{
pipe(); // created 3 & 4
int pid = fork();
if (pid == 0)
{
system("ifconfig 1>&4");
echo theEnd 1>&4; // no eof eas delivered
// execl(/bin/bash,"-c","ifconfig"); // could not get this to send to 4
exit(0); // would not be needed with an exec
}
else
{
char buf; // If no read a line, why a larger buffer?
while(read(3,&buf,1) > 0) // could not figure out how to read a line
{
construct lines, parse, ....
if (a line contains "theEnd") // never got eof
break;
}
waitpid(pid);
close(3);
close(4);
}
}

popen() was rejected because of potential problems between
FILE and C++ I/O.

There must be a better way. Advice and possible reference
to a tutorial or example would be much appreciated.

Thanks,
Mike.