Which is the best way of getting the output from an execl() call? This call generates some console output and I need to do some kind of capture.
Thanks,
Daniel.
Which is the best way of getting the output from an execl() call? This call generates some console output and I need to do some kind of capture.
Thanks,
Daniel.
Pipe it.
Quzah.
Hope is the first step on the road to disappointment.
Thanks Quzah for your reply.
Does freopen use pipes?
I'm doing
FILE* fpStdout = freopen(STDOUTFILE, "w+", stdout);
system("ls");
Then use fgets() like you would for any other regular file.Code:FILE *fp = popen("ls","r"); pclose(fp);
Is "ls" just an example, or are you really trying to use ls to get a directory listing into the program?
If so, look up opendir / readdir / closedir
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.