
reading output produced by an archive
Quote:
> I have a C program that links with an archive that sends its
> output to stdout. Is there a way to capture this output and
> use it in my program?
> I have thought of reopening stdout using freopen but that
> closes stdout. I need stdout because my final output is
> expected to be printed to stdout. I guess I need to redirect
> stdout to stdin or a file and then reset it back to how it
> was originally. Is there a simple way to do that?
This is all OS-specific stuff. If you're on a Posix system, then you can
run the vital functions in a subprocess, with stdout changed to a pipe.
If you're running DOS, you're probably doomed. I don't know about Windows.
You *may* be able to assign stdout to something else, if your system
allows that. I don't think there's a portable way of doing it that doesn't
involve multiple processes.
The alternative solution involves getting a large shotgun and going to
look for the programmer who wrote the library.
--
+- David Given ---------------McQ-+ According to the latest official figures,
+- http://wired.st-and.ac.uk/~dg -+
--