By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

How to Modify Console output AFTER it has gone to cout

P: n/a
Is this possible using ANSI libraries? If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?

many thanks in advance,
Robby

Aug 6 '07 #1
Share this Question
Share on Google+
9 Replies


P: n/a
re*******@gmail.com wrote:
Is this possible using ANSI libraries?
What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?
You can try to "capture" or "redirect" the standard output in a different
stream, and then you can do anything you want with that stream's buffer.
Standard output redirection, however, is implementation- and platform-
specific. Ask in the newsgroup for your OS or your compiler.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Aug 6 '07 #2

P: n/a
Alf P. Steinbach schrieb:
* re*******@gmail.com:
>Is this possible using ANSI libraries? If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?

The C++ standard doesn't mention "ANSI libraries", "exe", "black box",
"DLL", or "console".

IOW., you're way off-topic -- pray tell, why didn't you post in a Java
group?

Please, next time, do so, or, see the FAQ which lists a number of
Windows programming group suggestions.
Why do you suggest a Java group?

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Aug 6 '07 #3

P: n/a
On Aug 6, 7:39 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
realro...@gmail.com wrote:
Is this possible using ANSI libraries?
What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?
You can try to "capture" or "redirect" the standard output in a different
stream, and then you can do anything you want with that stream's buffer.
Standard output redirection, however, is implementation- and platform-
specific. Ask in the newsgroup for your OS or your compiler.
It's not too clear to me what the situation actually is. If the
DLL outputs to cout/cerr, it's relatively simple to connect
these streams to your own filtering streambuf, and do whatever
you want. If the DLL outputs using system level functions (the
Windows equivalent of write), then there's probably nothing he
can do.

--
James Kanze (GABI Software) email:james.kanze:gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Aug 6 '07 #4

P: n/a

Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
Alf P. Steinbach schrieb:
>
IOW., you're way off-topic -- pray tell, why didn't you post in a
Java
group?
[snip]

Why do you suggest a Java group?

Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.
--
Bob <GR
POVrookie
Aug 7 '07 #5

P: n/a
On Aug 6, 5:22 pm, James Kanze <james.ka...@gmail.comwrote:
On Aug 6, 7:39 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
realro...@gmail.com wrote:
Is this possible using ANSI libraries?
What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
If I have an exe that calls a
black box DLL, and the DLL writes to the console, how can I get my exe
to grab what the DLL wrote, modify it, and spit out a modified form of
said output?
You can try to "capture" or "redirect" the standard output in a different
stream, and then you can do anything you want with that stream's buffer.
Standard output redirection, however, is implementation- and platform-
specific. Ask in the newsgroup for your OS or your compiler.

It's not too clear to me what the situation actually is. If the
DLL outputs to cout/cerr, it's relatively simple to connect
these streams to your own filtering streambuf, and do whatever
you want. If the DLL outputs using system level functions (the
Windows equivalent of write), then there's probably nothing he
can do.

--
James Kanze (GABI Software) email:james.kanze:gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Err, yes, I meant STL libraries, not ANSI libraries. The DLL outputs
through low-level functions and not throuh std::cout or std::cerr,
which is why setting up a filter isn't a trivial task. I was just
wondering if the STL libraries could do anything, as I tend to avoid
platform-dependent code where possible. I gather from the replies that
it's not as simple as I'd hoped.

Thanks,
Robby

Aug 7 '07 #6

P: n/a
On Aug 7, 6:50 pm, realro...@gmail.com wrote:
Err, yes, I meant STL libraries, not ANSI libraries. The DLL outputs
through low-level functions and not throuh std::cout or std::cerr,
which is why setting up a filter isn't a trivial task. I was just
wondering if the STL libraries could do anything, as I tend to avoid
platform-dependent code where possible. I gather from the replies that
it's not as simple as I'd hoped.
In that case, there may be nothing you can do. There's
certainly nothing portable. About the only thing I can suggest
is closing the file descripters (handles under Windows?) for
standard out and standard error, and trying to reopen them to
something else. (This would be the usual solution under Unix,
but it might also work under Windows.)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Aug 8 '07 #7

P: n/a

Alf P. Steinbach <al***@start.nowrote in message...
* BobR:
Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
[snip]
>Why do you suggest a Java group?
Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.

Hm. Well. :-)

I think perhaps "Hi Alf" is off-topic in this group, but AFAICS the FAQ
doesn't list any more suitable group...
<Grrrrr>

#include <iostream>
int main(){
std::cout<<"Hello Mr. Steinbach."<<std::endl;
return 0;
} // :-}

--
Bob <GR
POVrookie
Aug 9 '07 #8

P: n/a
BobR wrote:
Alf P. Steinbach <al***@start.nowrote in message...
>* BobR:
>>Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
[snip]
Why do you suggest a Java group?
Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.
Hm. Well. :-)

I think perhaps "Hi Alf" is off-topic in this group, but AFAICS the FAQ
doesn't list any more suitable group...

<Grrrrr>

#include <iostream>
int main(){
std::cout<<"Hello Mr. Steinbach."<<std::endl;
return 0;
} // :-}
What... No templates?

#include <iostream>

class Alf { };

template<typename T>
void say_hi_to_newsgroup(const T&)
{
std::cout << "Hi Newsgroup!" << std::endl;
}

template<>
void say_hi_to_newsgroup<Alf>(const Alf&)
{
std::cout << "Hello Mr. Steinbach." << std::endl;
}

int main()
{
say_hi_to_newsgroup(Alf());
return 0;
}
Aug 9 '07 #9

P: n/a

red floyd <no*****@here.dudewrote in message...
BobR wrote:
Alf P. Steinbach <al***@start.nowrote in message...
* BobR:
Alf P. Steinbach <al***@start.nowrote in message...
* Thomas J. Gritzan:
[snip]
Why do you suggest a Java group?
Why not? <g>
Does Starbucks count as a 'Java group'?

Hi Alf.
Hm. Well. :-)

I think perhaps "Hi Alf" is off-topic in this group, but AFAICS the FAQ
doesn't list any more suitable group...
<Grrrrr>

#include <iostream>
int main(){
std::cout<<"Hello Mr. Steinbach."<<std::endl;
return 0;
} // :-}

What... No templates?
KISS prevented me from doing that (Homey don't play dat!).

--
Bob <GR
POVrookie
Aug 9 '07 #10

This discussion thread is closed

Replies have been disabled for this discussion.