Can we convert the RWCString to std::string? If yes how?

Discussion in 'C++' started by varsha.gadekar, Jan 10, 2007.

  1. I want to convert the message of type RWCString to std::string type.
    How can we do this?
    varsha.gadekar, Jan 10, 2007
    1. Advertisements

  2. varsha.gadekar

    Ondra Holub Guest

    Since RWCString is not C++ standard class, there is no C++ standard way
    how to do it. I do not know RWCString, so I can only guess:

    - look into RWCString documentation and try to find there some
    converting function
    - there may be also some method, whcih gives the buffer occupied by
    RWCString. This may be used as one input parameters for std::string
    - if RWCString can be written into output stream, you can srite it to
    std::eek:stringstream and get the string with method str() from there
    Ondra Holub, Jan 10, 2007
    1. Advertisements

  3. varsha.gadekar

    Jim Langston Guest

    I googled for RWCString, and see it has an operator char*. So:
    std::string MyString( RWCString );
    *should* work.
    Jim Langston, Jan 10, 2007
  4. Thanks to you both it is working. But i need to check if it works for
    large message stream
    varsha.gadekar, Jan 10, 2007
  5. varsha.gadekar

    Frank Potter Guest

    then read a very large text file and test it,
    it's easy to find out if it works for huge strings.
    Frank Potter, Jan 10, 2007
  6. varsha.gadekar

    Mehturt Guest

    This won't work if the string contains character with ascii value 0.
    In this case you need the length of RWCString as well.
    Mehturt, Jan 10, 2007
  7. varsha.gadekar

    Satish Guest

    You can use the data() function of RWCString class to get char *

    RWCString testString("Hellow")
    cout <<

    You can use this further to initialise std::string objects. Hope this
    Satish, Jan 10, 2007
  8. varsha.gadekar

    BobR Guest

    Frank Potter wrote in message ...
    Do not top-post!

    std::string Tst("");
    BobR, Jan 10, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.