🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.c++.moderated
1 messages
1 total messages Started by Kyle F. Downey Mon, 08 Apr 1996 21:40
redefining stdout for all C/C++ output calls
#66
Author: Kyle F. Downey
Date: Mon, 08 Apr 1996 21:40
28 lines
1623 bytes
Is there any way to redefine stdout that will work for both C-style
(printf, etc.) and C++-style (streams) output? I would want a C++
method that does this

void f() {
	printf("Here's a C-style output line.\n");
	cout << "Here's another using streams..." << endl;
}

to send the output to a different stream. I know there's tie() for
streams, but what about printf()? The idea here is to take a
text-based C++ program and "capture" all screen writes to send them to
an GUI window "stream." I want to do it so the text program need not be
rewritten. So you would take the main() function of the program and
call it, say, tmain() and pass it as a function pointer to a program
that would run it after redefining stdout.

Any ideas?

(If you've seen the SIOUX library under the Metrowerks C/C++ compiler,
you'll know what I am thinking about.)

--kd

      [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
      [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
      [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
      [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads