stringstream simple problem, simple solution?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jjblt206
    New Member
    • Oct 2008
    • 1

    #1

    stringstream simple problem, simple solution?

    Hi,

    I have a simple nit-picky question. It would be nice for a stringstream to have a member function which returns a C style string (just like a string does) so I could do this,

    Code:
    stringstream ss;
    ss << "Etc...";
    ss.c_str()
    instead of this,

    Code:
    stringstream ss;
    ss << "Etc...";
    ss.str().c_str()
    Is it possible to do something like this?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Did you try this?

    stringstream can present itself as a string using the str() member function. That member function returns a string. A string can present itself as a C-string by using the c_str() method.

    So, ss.str().c_str( ) should work fine.

    Comment

    Working...