Ok suppose I have a program ( in windows a .exe file ) and when I run it, it outputs some information… now I’m writing another program ( in c++ ) and I need it to automatically run that .exe file and read the output so that it can process that information for further actions…
what should I do ?
Use
popenor on windows (per comment)_popen. Basically it functions as the thing behind the|insome program | thing.Normally I’m against posting complete code but I literally wrote this today and have it on hand, so, here you go. From what I understand C++ doesn’t have a great interface that replaces
popenbut if you’re bringing in the boost libraries or something at that layer there are solutions.Note I use
char[10]because in my application I know the output will be that short.