streams again

M

Michael Shestero

Hello.

I have three question about ofstream and ifstream.

1. I have a function that writes some text-output into ofstream. The
reference to that ofstream it got as a parameter. I have no access to source
code of it. I need redirect the output to somehing, for example to a CEdit
control.

2. I have a function that writes some text into cerr (stderr). No
parameters. No access to source code. I need redirect the output to
somehing, for example to a CEdit control.

3. I have a function that reads text from cin (stdin). No parameters. No
access to source code. I need to send into this function text from my char[]
or from CEdit control.

I know a bit about redirection of stdin and stdout for a child process using
pipes and streambuf overlapping. But there is only one process in my
application.
I can create a thread, but I don't want it.

Best regards,
Shestero Michael
 
C

Chris Theis

Michael Shestero said:
Hello.

I have three question about ofstream and ifstream.

1. I have a function that writes some text-output into ofstream. The
reference to that ofstream it got as a parameter. I have no access to source
code of it. I need redirect the output to somehing, for example to a CEdit
control.

2. I have a function that writes some text into cerr (stderr). No
parameters. No access to source code. I need redirect the output to
somehing, for example to a CEdit control.

3. I have a function that reads text from cin (stdin). No parameters. No
access to source code. I need to send into this function text from my char[]
or from CEdit control.

I know a bit about redirection of stdin and stdout for a child process using
pipes and streambuf overlapping. But there is only one process in my
application.
I can create a thread, but I don't want it.

Best regards,
Shestero Michael

You will have to ask this specific questions in a Microsoft VC newsgroup
because this newsgroup deals with standard C++ issues only.

[off-topic]
If I remember correctly there is a way of at least redirecting output from
cout to a window, as MS uses it for its Visual Studio. Try
ww.codeguru.com - I think I once saw a discussion about that there.

Chris
 
M

Mike Wahler

Michael Shestero said:
Dear Chris,

Well, forget about CEdit and Microsoft! Read char[] instead CEdit. My
question is about the streams redirection in standart C++, not about the
features of CEdit.
ofstream and ifstream is in Borland C++, GNU C++, MS VC++. The three
functions I have mentioned in my questions can be compiled in all above and
also in IAR eMbedded C++.
I guess this is quite standart C++ issue, isn't it?

You can, with standard C++, 'redirect' i/o to/from std::string
objects, using stringstreams. Character arrays can be inserted/
extracted to/from std::string objects.

Read about stringstreams.

-Mike
 
M

Michael Shestero

Dear Chris,

Well, forget about CEdit and Microsoft! Read char[] instead CEdit. My
question is about the streams redirection in standart C++, not about the
features of CEdit.
ofstream and ifstream is in Borland C++, GNU C++, MS VC++. The three
functions I have mentioned in my questions can be compiled in all above and
also in IAR eMbedded C++.
I guess this is quite standart C++ issue, isn't it?
To tell the compleate story the metter is that I try to leave this three
functions on standart C++ for source-level compatability, that's why I don't
want to change their code during integration into my MFC application.

Bye.
I have three question about ofstream and ifstream.

1. I have a function that writes some text-output into ofstream. The
reference to that ofstream it got as a parameter. I have no access to source
code of it. I need redirect the output to somehing, for example to a CEdit
control.

2. I have a function that writes some text into cerr (stderr). No
parameters. No access to source code. I need redirect the output to
somehing, for example to a CEdit control.

3. I have a function that reads text from cin (stdin). No parameters. No
access to source code. I need to send into this function text from my char[]
or from CEdit control.

I know a bit about redirection of stdin and stdout for a child process using
pipes and streambuf overlapping. But there is only one process in my
application.
I can create a thread, but I don't want it.

Best regards,
Shestero Michael

You will have to ask this specific questions in a Microsoft VC newsgroup
because this newsgroup deals with standard C++ issues only.

[off-topic]
If I remember correctly there is a way of at least redirecting output from
cout to a window, as MS uses it for its Visual Studio. Try
ww.codeguru.com - I think I once saw a discussion about that there.

Chris
 

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

Similar Threads

flushing streams 3
Need help again please 19
"Streams" 8
Java 8 Streams and Eratosthenes 22
Connecting File Streams 1
Retrieving data from software GUI 0
Communicating between processes 0
Basic question on streams 16

Members online

No members online now.

Forum statistics

Threads
474,147
Messages
2,570,833
Members
47,380
Latest member
AlinaBlevi

Latest Threads

Top