How to Modify Console output AFTER it has gone to cout

R

realrobby

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
 
A

Alf P. Steinbach

* (e-mail address removed):
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.
 
V

Victor Bazarov

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
 
L

Laurent D.A.M. MENTEN

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

This is not C++ related... anyway, check your OS documentation for
redirection of standard input and output or your C book for dup() and
dup2() functions.
 
T

Thomas J. Gritzan

Alf said:
* (e-mail address removed):

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?
 
J

James Kanze

What does "ANSI libraries" mean? Do you mean "the Standard Library"?
If so, the answer is "no".
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.
 
R

realrobby

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
 
J

James Kanze

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.)
 
A

Alf P. Steinbach

* BobR:
Alf P. Steinbach said:
* 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.

Hm. Well. :)

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

BobR

Alf P. Steinbach said:
* BobR:
Alf P. Steinbach said:
* 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;
} // :-}
 
R

red floyd

BobR said:
Alf P. Steinbach said:
* BobR:
* 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;
}
 
B

BobR

red floyd said:
BobR said:
Alf P. Steinbach said:
* BobR:
* 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!).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top