Re: Any way to capture stdcout output to memory?
- From: gazelle@xxxxxxxxxxxxxxxxxxxxx (Kenny McCormack)
- Date: Fri, 2 May 2008 12:41:45 +0000 (UTC)
In article <raDSj.3$xb2.2@xxxxxxxxxxxx>,
Jim Langston <tazmaster@xxxxxxxxxxxxxx> wrote:
....
".. modify your source..."
If I was able to modify the source I'd have it write to a memory buffer in
the first place. The problem is the actual output is being produced deep
inside a library call. This right now is not an option, although I may have
to make it an option if I can't find a good way to do it. I think one of
the methods of redirecting stdout will work, although it looks like I'll
have to use a thread which I don't like but *shrug*
I, too, have hit this issue. First comment: You (Jim) have made it
clear that the platforms is Windows, not Unix, right? I think some of
the posters are assuming Unix. Unix would simplify things, since these
sorts of things are always easier there. Things like dup(), etc,
although often implemented in Windows, often don't work quite the same
under Windows as under Unix.
On Windows, I was able to solve the problem (very OT for clc, of course)
by diddling with the elements of the the FILE structure. The basic
trick is that you set the buffersize very high, so that it _never_ gets
written out. Then, your main program extracts the information out of
the stdout buffer (pointed to by one of the elements in the FILE
structure). I did this using the MinGW compiler - but I would imagine
it is doable with most compilers.
I think that the thread solution is actually better, but is, as you say,
complicated to implement. I wish somebody would do it, though, and make
the code publicly available.
P.S. Note that even if source is available and that modifying it to
call different functions was an option, it is possible that doing so
would be too difficult - if, for example, the existing code makes many,
many calls to stdout, intermixing different functions, etc.
.
- Follow-Ups:
- Re: Any way to capture stdcout output to memory?
- From: Richard Tobin
- Re: Any way to capture stdcout output to memory?
- References:
- Any way to capture stdcout output to memory?
- From: Jim Langston
- Re: Any way to capture stdcout output to memory?
- From: CBFalconer
- Re: Any way to capture stdcout output to memory?
- From: Jim Langston
- Any way to capture stdcout output to memory?
- Prev by Date: Re: K&R2, exercise 6.4
- Next by Date: Re: K&R2, exercise 6.4
- Previous by thread: Re: Any way to capture stdcout output to memory?
- Next by thread: Re: Any way to capture stdcout output to memory?
- Index(es):
Relevant Pages
|