Logo Search packages:      
Sourcecode: gcc-2.95 version File versions

bug-115978.cc

#include <sstream>
#include <iostream>

void
writer(int i)
{
    static stringstream sstr;

    // shove some stuff into the stringstream
    sstr << "This is a fubar test. " << i;
    sstr.unsetf(ios::skipws);   // keep spaces

    char c = 'Q'; // A throwaway that appears nowhere in the message
    while (sstr >> c)
    {
        // print out each character and its hex representation.  It
        // should stop printing out when the end of the string is
        // reached.
        cout << c << "[" << hex << static_cast<int>(c) << "] ";
        c = 'Q';
    }
    cout << "\n----------------" << endl ;

    // reset the stringstream after it has gone out of good state
    sstr.clear();
}

int 
main()
{
    for (int i = 0; i != 2; ++i)
    {
        writer(i);
    }
    
    return 0;
}

Generated by  Doxygen 1.6.0   Back to index