473,378 Members | 1,370 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

strstream and ostrstream with new g++

Hi,

An old code is using stuff like
#include <strstream.h>
ostrstream *m_actionStream;
and the compiler complained syntax error before `*' token

I followed some previous posts and tried things like
#include <strstream.h>
or
#include <sstream>
and
std::ostringsteam *m_actionStream;
but all in vain.

Is there any simple way (adding a couple of lines) to make the old code
work, instead of rewriting everything?
Thanks

Jul 22 '05 #1
2 3850
b8*******@yahoo.com wrote:
Hi,

An old code is using stuff like
#include <strstream.h>
ostrstream *m_actionStream;
and the compiler complained syntax error before `*' token

I followed some previous posts and tried things like
#include <strstream.h>
or
#include <sstream>
Try #include <strstream>
and
std::ostringsteam *m_actionStream;
but all in vain.

Is there any simple way (adding a couple of lines) to make the old
code work, instead of rewriting everything?
Thanks


Jonathan
Jul 22 '05 #2
b8*******@yahoo.com wrote:
An old code is using stuff like
#include <strstream.h>
This header is no called <strstream> and it is deprecated. However,
deprecation just means that you should probably not use it in new
code and you might want to consider replacing it in old code if you
are working on it anyway.
ostrstream *m_actionStream;
The 'ostrstream' class is know declared in namespace 'std', i.e.
want to use one of the following:

- 'std::ostrstream* m_actionSteram;'
- 'using std::ostrstream;' and leave the definition as is.
- 'using namespace std;' and leave the definition as is.

(listed in order of my preference).

The advantage of the latter two approach over the first one is that
you can put the stuff at just one location, e.g. immediately after
the include directive. However, you should not use the 'using'
approaches at the global scope in headers (the name of your
variable seems to indicate that it is actually a member of a class).
Is there any simple way (adding a couple of lines) to make the old code work, instead of rewriting everything?


Essentially, this should do the trick:

| #include <strstream>
| using std::ostrstream;

If this does not work, please post a complete code excerpt which
displays the problem (and has no other problems...).
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: vishnu mahendra | last post by:
hello to all, #include<iostream.h> #include<conio.h> #include <strstream.h> void main() { clrscr(); strstream str; char *a = new char; int i;
9
by: Charles Prince | last post by:
How do I reuse a ostrstream? So far I have replaced all code that does this "delete <ostrstream>.str()" with "<ostrstream>.freeze(0)"
1
by: News For Mohan | last post by:
Hi, I am using ostrstream object.I am using the str() function to get the char buffer. The function is returning the pointer of char buffer , but it is adding some garbage at the end. This...
2
by: derek | last post by:
Hi, I'm trying to compile someone's code which uses ostrstream. I know it's declared in file strstream, but I can't find this file in the /usr/include/c++/3.3.3 directory. There is a file called...
7
by: forrest | last post by:
I wrote a function like this: #define LEN 8 void foo(ostream& decry_stream ) { ifstream ifile( filepath.c_str(), ios_base::binary ); while ( !ifile.eof() ) { ifile.read((char...
1
by: tcl | last post by:
Questions on ostrstream. #1) do I have a memory leak as the control exits the scope { ostrstream os; os << "hello world" << endl << ends; }
2
by: Praveen Chandra | last post by:
Hi, I am trying to build a static library, while building the library i am getting the following error: fatal error C1189: #error : "No sstream/strstream implementation" Following is the...
1
by: GeeBee | last post by:
1) I’m using Borland C++ Builder 1.0 (a very old (but still good) version). 2) I have an application EXE calling a DLL. 3) A function in the DLL receives a parameter defined as "ostream &" , and...
5
by: nithya4u | last post by:
I am working on a c++ module, where large amount of data needs to be written to a stream and str() method is been used to assign the value of this to the char*. This produces the intended result....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.