I am developing a program that I plan to implement in C, and I have a question about the best way (in terms of performance) of invoking external programs. A user will provide my program with a file name, and then my program will run another program with this file as input. Then my program will process the output of another program.
My typical approach would be to redirect the output of another program to a file, and then my program would read that file when it is done. However, I understand that I / O operations are quite expensive, and I would like to make this program as efficient as possible.
I looked a little and I found the popen command to run system commands and capture output. How does the performance of this approach compare with the performance of the approach I described? popen just write the external output of the program to a temporary file or does it save the program in memory?
Alternatively, is there another way to do this in order to provide better performance?
source share