View Poll Results: Do you like this?

Voters
4. You may not vote on this poll
  • Yes!

    1 25.00%
  • Neutral, I don't care.

    2 50.00%
  • No.

    1 25.00%

Thread: "datastream" class

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    417

    "datastream" class

    This isn't too useful (and there might be a standard STL that does this anyway), but this might make coding more convenient.

    When you pass this object data, it uses sprintf to convert it to a string.

    Code:
    datastream x;
    x << 5;
    int y;
    x >> y;
    That basically would assign y the value of 5.

    You can use the indexing operators, cout it, cin to it... ifstream, ofstream...

    Enjoy! Its not very complex, but it could be useful (if there is a built in one, please tell me so I can look it up)
    Last edited by Trauts; 05-18-2003 at 11:56 AM.

  2. #2
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    There is a built-in object that is called std::stringstream in the <sstream> header.
    It reads and writes data to and from a string.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    how do you use it, and does it let you search using the indexing op?

    datastream x = 12345;

    x[x["23"]] will work, as long as 23 is found
    Last edited by Trauts; 05-18-2003 at 11:52 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Specializing class
    By Elysia in forum C++ Programming
    Replies: 6
    Last Post: 09-28-2008, 04:30 AM
  2. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 01:03 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. class errors
    By romeoz in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2003, 07:57 PM