Hello, I noticed a bad output using the automatic storage allocation
ostrstream a;
The problem disappear using the alternative constructor (with fixed buffer dimension)
ostrstream os(char** buf, int sz, ios::app);
Using the first constructor it comes wrong chars on my monitor, using Dev-C++.
The same program compiled with Borland C++ works fine...
Did anyone detected the same?
(The sources I used are taken from Bruce Eckel's Thinking C++, so I don't post their)
Thanks,
Paolo Ferraresi.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-07-04
Give more information. Use the stringstream class.
Zero Valintine
#include <iostream>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(int argc, char ** argv){
stringstream a;
a << "Text: " << "Zero Valintine" << '\n';
a << "Interger: " << 20 << '\n';
a << "Float: " << 5.5 << '\n';
cout << a.str();
system("PAUSE > NUL");
return(0);}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Zero,
I knew the use of sstream were deprecated, (and Eckel doesn't mention about it in his book).
I got problems using sstream with Dev-C++ 4 but now I tried and works fine...
What is the more C++ standard compliant about string stream?
Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
the standard says: include sstream, and use classes istringstream, ostringstream, and/or stringstream, in the std namespace
Zero's example is very good
Adrian
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I noticed a bad output using the automatic storage allocation
ostrstream a;
The problem disappear using the alternative constructor (with fixed buffer dimension)
ostrstream os(char** buf, int sz, ios::app);
Using the first constructor it comes wrong chars on my monitor, using Dev-C++.
The same program compiled with Borland C++ works fine...
Did anyone detected the same?
(The sources I used are taken from Bruce Eckel's Thinking C++, so I don't post their)
Thanks,
Paolo Ferraresi.
Give more information. Use the stringstream class.
Zero Valintine
#include <iostream>
#include <cstdlib>
#include <sstream>
using namespace std;
int main(int argc, char ** argv){
stringstream a;
a << "Text: " << "Zero Valintine" << '\n';
a << "Interger: " << 20 << '\n';
a << "Float: " << 5.5 << '\n';
cout << a.str();
system("PAUSE > NUL");
return(0);}
Hello Zero,
I knew the use of sstream were deprecated, (and Eckel doesn't mention about it in his book).
I got problems using sstream with Dev-C++ 4 but now I tried and works fine...
What is the more C++ standard compliant about string stream?
Thank you!
the standard says: include sstream, and use classes istringstream, ostringstream, and/or stringstream, in the std namespace
Zero's example is very good
Adrian