When I try to convert a string into a string stream (see code below) I get
the following error message:
Could not find a match for 'istrstream::istrstream
(std::basic_string<char,std::string_char_traits<char>,std::allocator<char>>)
'
1) Why is that and what syntax should I be using instead of "istrstream
inLine(s1);" ???
2) How do I configure Borland's C++ Builder to give more detailed error
messages?
Code:
#include <string>
#include <iostream.h>
#include <strstrea.h>
using namespace std;
int main() {
string s1;
cout << "Enter something: ";
getline(cin, s1, '\n');
istrstream lineIn(s1);
return 0;
}
Thanks,
Michael Hansen
PS. Using "istrstream inLine(s1.c_str());" I get the error message: Could
not find a match for 'istrstream::istrstream (const char*)'
istrstream doesn't work on C++-"string". You have to write
istrstream lineIn( const_cast<char*>( s1.c_str() ) );
Casting away constness is necessary because istrstream expects a non-const
C-style char pointer and string::c_str() gives a const pointer.
The new C++-standard defines a "istringstream" in the header <sstream>
(says Bjarne Stroustrup). Is this available in Builder 3?
--
Wilfried Cordes
DDBST Software and Separation Technology GmbH
>The new C++-standard defines a "istringstream" in the header <sstream>
>(says Bjarne Stroustrup). Is this available in Builder 3?
Yes, it's available - an 'include <sstream>' will bring it in.
-------------------------------------------
Patrick Bennett
Acraline Products, Inc.
pben...@acraline.com
Mike Hansen
I have sstream.cc and sstream.h in my cbuilder3\include directory. If it
belches on #include <sstream>, then your include directory isn't set
correctly.