streams again

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Shestero

    streams again

    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


  • Chris Theis

    #2
    Re: streams again


    "Michael Shestero" <shestero@cyber .miem.edu.ru> wrote in message
    news:bpip27$1oo as2$1@ID-54498.news.uni-berlin.de...[color=blue]
    > 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[/color]
    source[color=blue]
    > 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[/color]
    char[][color=blue]
    > or from CEdit control.
    >
    > I know a bit about redirection of stdin and stdout for a child process[/color]
    using[color=blue]
    > 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
    >[/color]

    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


    Comment

    • Michael Shestero

      #3
      Re: streams again - standart C++

      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.
      [color=blue][color=green]
      > >
      > > 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[/color]
      > source[color=green]
      > > code of it. I need redirect the output to somehing, for example to a[/color][/color]
      CEdit[color=blue][color=green]
      > > 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[/color]
      > char[][color=green]
      > > or from CEdit control.
      > >
      > > I know a bit about redirection of stdin and stdout for a child process[/color]
      > using[color=green]
      > > 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
      > >[/color]
      >
      > 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[/color]



      Comment

      • Mike Wahler

        #4
        Re: streams again - standart C++


        "Michael Shestero" <shestero@cyber .miem.edu.ru> wrote in message
        news:bpjdqu$1mp enq$1@ID-54498.news.uni-berlin.de...[color=blue]
        > 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[/color]
        and[color=blue]
        > also in IAR eMbedded C++.
        > I guess this is quite standart C++ issue, isn't it?[/color]

        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


        Comment

        Working...