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

streams again

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Michael Shestero" <sh******@cyber.miem.edu.ru> wrote in message
news:bp*************@ID-54498.news.uni-berlin.de...
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
Jul 22 '05 #2

P: n/a
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


Jul 22 '05 #3

P: n/a

"Michael Shestero" <sh******@cyber.miem.edu.ru> wrote in message
news:bp*************@ID-54498.news.uni-berlin.de...
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
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.