Hi, I need to get the output of a program called with the system() function. How would I do this?
TheBeast32
54
Posting Whiz in Training
Recommended Answers
Jump to PostWell, that gonna be difficult using the system function, since the function doesn’t return anything expect the status i.e 0 or 1.
What you could do is pipe the output to a file and access that file to get the output of that program.
Or you will have …
Jump to PostFILE *fp = popen("myprog.exe", "r" ); while ( fgets( buff, sizeof buff, fp ) != NULL ) { // do stuff with lines } pclose( fp );
Use _popen() on windows.
All 7 Replies
ssharish2005
62
Posting Whiz in Training
TheBeast32
54
Posting Whiz in Training
ssharish2005
62
Posting Whiz in Training
Salem
5,138
Posting Sage
Alex Edwards
commented:
You deserve more than just +1 for all the help you give, but here you go.
+2
Nick Evan
commented:
I'll make it +9 then
+8
marco93
-87
Junior Poster
ssharish2005
62
Posting Whiz in Training
TheBeast32
54
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.