473,795 Members | 2,911 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having troubles with ostrstream: Borland C++ Builder 1.0

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 writes error messages to this stream using the “<<” operator.
4) The EXE file creates an ostrstream variable and passes this to the
DLL function.
5) After the DLL function has finished, the EXE writes some text to an
output file, followed by the ostrstream which has been “filled” by the
DLL function.
6) There is erratic extraneous characters in the final output string,
which appear to come from some corruption of the output from the DLL
process.
7) Both application and DLL are using memshare.hpp and linked with bcbmm.lib

DLL:
unsigned int process(LPCSTR x, ostream & Messages)
{ ….
errorcode = 44;
Messages << “error code ” << errorcode << endl;
……
return errorcode;
}
EXE:
ostrstream MessageBuffer;
// call the DLL process
if (process(“some data here”, MessageBuffer) != 0)
{debugfile << “*error in process*: “<<MessageBuffe r.str()
<< endl;
….}

Result:
*error in process*: error code 44 then-a-selection-of-rubbish-characters

If I pass an ofstream (file) to the DLL process (instead of an
ostrstream) the error code is written directly to the output file with
no extraneous characters.

If I use a specific buffer to initialize the ostrstream, all is OK,
there are no extra characters
e.g. char space[2000];
memset(space, 0x00, sizeof(space));
ostrstream MessageBuffer(s pace, sizeof(space));

I have also tried creating a temporary output file in the EXE, passing
this to the DLL process, then closing it, re-opening it and reading it
back in with getline() and dumping it back out to the desired output
file – this also works OK with no extraneous characters.

The junk text at the end only appears when I create a default ostrstream
and pass this to the DLL process. It seems the junk comes from the
remainder of the internal string buffer used by the ostrstream.

Any ideas why, or how to prevent it?
Oct 3 '06 #1
1 2380
On Tue, 03 Oct 2006 21:07:47 +0200, GeeBee <no**@nowhere.n etwrote in
comp.lang.c++:
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.
[snip]

Stop right there, and get thee to Borland's support groups on the
server nntp://newsgroups.borl and.com.

There is no such thing as a DLL in the C++ language, this is all
compiler and Windows specific.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.l earn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Oct 4 '06 #2

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

Similar topics

5
2771
by: Steven O. | last post by:
First, sorry if by some chance I am not posting to the correct newsgroups, these seemed to be the most applicable to my question (see disclaimer at end of post for further comments....). Started with the Borland web site, and it didn't answer my questions, so I hope someone here will be kind enough to reply. I took a few courses on C++ using Microsoft Visual C++, and then taught myself MFC for GUI design -- an exercise akin to using...
11
2138
by: TGF | last post by:
I am wondering if it is feasible to use .NET for applications that have to be very fast. We have a few applications that are blazingly fast, written in Borland C++ using Borland C++ Builder. We would like to port over to ..NET, but some of the test models we have developed are MUCH, MUCH slower than it's Borland counterpart. Is this due to the .NET Framework and the JIT? Or is it something we should be looking for in the project...
9
7465
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)"
17
4705
by: Ziggi | last post by:
Hi. I want to get a C++ IDE, but I dont know whether to go for Bill Gate's solution or Borland's. Could any kind folks detail the relative strength and weaknesses of both, and also tell me which you yourselves prefer. Thanks in advance. Ziggi
15
3779
by: Chris | last post by:
I am just beginning programming again and need a bit of advice. I have both Visual C++ 6.0 Standard Edition and Borland C++ Builder 6. Of these two which do you consider the best for programming windows programs (not the DOS style program). I have had a quick look at both of these and Borland seems to have a lot more components (Buttons, Forms etc) than Microsoft Visual C++. Does Visual C++ have these components easily accesable. Chris.
24
3827
by: serdar | last post by:
Hi. Does anybody say that what is better borland c++ or visual c++? Which compiler does have more help?
0
3113
by: Xproblem | last post by:
FTP Client Engine for C/C++ 2.4 Screenshot - Soft.comFTP Client Engine for C/C++ 2.4. ... System Requirements: Windows C/C++ compiler - Microsoft operating system: Windows 95, Windows 98, Windows ME, ... www.soft30.com/screen-70-11625.htm - 31k - Cached - Similar pages C++ Server Pages 1.6 - Soft.comC++ Server Pages (CSP) allows developers to build Dynamic Web Pages and Web ... Existing C++ projects can be ported to the Web by simply...
22
2242
by: smartwolf agassi via DotNetMonster.com | last post by:
I'm a C# language learner. I want to know which IDE is better for C# programing, Borland C#Builder or VS.net 2003? -- Message posted via http://www.dotnetmonster.com
17
7258
by: Fabry | last post by:
Hi All, I'm new of this group and I do not know if this is the correct group for my question. I have a DLL with its export library (.lib) wrote in Borland C++ 6. In borland everything is OK and I am able to include the lib and use the class that i have exported creating an instance with new etc... I would like to export this class in microsoft VC++ using the same .lib file. Obviously it doesn' t work.
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.