strstream question

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

    strstream question

    I'm trying to use a string stored in a strstream object as the filename
    parameter in the open call on an fstream object.. It requires a const
    char* but no matter what I try I can't seem to get a raw pointer to the
    string stored in the strstream object.. Anyone have an idea I'm overlooking?

    Thanks in advance..

    --


  • Ron Natalie

    #2
    Re: strstream question


    "Bpb" <rdfNO@SPAMcomp uter.org> wrote in message news:631cb.2448 $pB6.2307@newsr ead2.news.atl.e arthlink.net...[color=blue]
    > I'm trying to use a string stored in a strstream object as the filename
    > parameter in the open call on an fstream object.. It requires a const
    > char* but no matter what I try I can't seem to get a raw pointer to the
    > string stored in the strstream object.. Anyone have an idea I'm overlooking?[/color]

    You just call the str() method on it.

    strstream ss;
    ss << "x.txt";
    fstream fstr(ss.str());

    Calling str() freezes the stream.

    strstreams are deprecated you know (in favor of stringstreams).

    ostringstream foo;
    foo << "x.txt";
    fstream fstr(foo.str(). c_str());



    Comment

    Working...