Issue with stringstream class
Silqun Leung
SLeung@ansoft.com
Thu Jan 2 18:48:00 GMT 2003
Hello,
I am having some difficulty with the stringstream class. Here is a
simple program I run:
#include <sstream>
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
std::string temp;
std::string stuff = "asdf asdf asdf asdf asdf"; std::stringstream a;
a << stuff.c_str();
std::cout << a.str() << std::endl;
a >> temp;
std::cout << a.str();
return 0;
}
The output when built with g++ is:
asdf asdf asdf asdf asdf
asdf asdf asdf asdf asdf
This is not what I expect when using the >> operator. I looked at the
stringstream class and do not see it overloading the >> operator and believe
that it should be inheriting from the same place as the ifstream class. When
I use the >> operator on a std::ifstream object, it is destructive, however
this does not appear to be the case for the stringstream object (which I
believe it should be). Using the same program with Visual C++ will yield
correct results (ie. an output of asdf asdf asdf asdf asdf asdf asdf asdf
asdf
Is this a bug in the implementation of the stringstream class?
Thanks,
Silqun
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list