#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    1
    Rep Power
    0

    clear ostrstream problem


    I am having a problem using the ostrstream class. The following piece of code:

    ostrstream *pBuffer;
    static ostrstream strbuf;

    pBuffer = &strbuf;
    strbuf << "insert into DayTimeStamp_01 values (" << *(msgCounter) << "," << days << "," << hours << "," << mins << "," << secs << ")";
    Query *myQuery = &queryTimeStamp;
    doQuery(myQuery, pBuffer);

    strbuf.clear();
    strbuf.seekp(0);
    strbuf.freeze(0);

    will execute approx 10+ times before it stops working. The above code is trying to insert values into a mysql database using the mysql++ api.

    I was just wondering if the above looked like an appropriate solution to reusing an ostrstream.

    - Thanks

    edit: might have helped to add my doQuery function :)
    void doQuery(Query *myQuery, ostrstream *strbuf)
    {
    string output(strbuf->str());
    myQuery->exec((cont string&)output);
    }
    Last edited by kidakira; July 14th, 2003 at 04:04 PM.

IMN logo majestic logo threadwatch logo seochat tools logo