This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Issue with stringstream class


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]