🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3433

OSTRSTREAM and sizing

#3433
From: Tim Ottinger
Date: Fri, 23 Feb 1996 23:27
52 lines
2611 bytes
Hi.

This might be a silly question, but a coworker of mine noticed this, and we've 
tested it on two compilers with similar results:

	#include <iostream.h>
	#include <strstream.h>
	int main (char * argc, char * argv[])
	{
 	  ostrstream str("abcdefg", 4);
   
  	 cout << "Length = " << str.pcount() << endl;
  	 cout << "Data   = " << str.str();
	}

produces the following output on both the GNU and HP C++ compilers
	Length = 0
	Data   = abcdefg

Two things were puzzling about this.  

The first was that the length parameter on the c'tor didn't seem 
to be used for anything, and the second was that I couldn't spot the 
right way to tell how big the buffer in the strstreambuf is (how many 
actual characters are in it).

It seems that "data" should have returned either "abcd", or "", 
rather than "abcdefg".  This tossed me.

My friend expected the 'pcount()' to tell him how many bytes are in
the buffer.

I can see some of this for istream(), though much still eludes.  For
an ostream, this is somewhat maddening.

Is is standard, and does it make sense?

******************************************************************************
* Tim Ottinger, Sr Tech				       tottinge@csci.csc.com *
* CSC Communications Industry Services		           217-351-8508x2420 *
* TRIS Division -- Cellular Billing and Support	            Fax 217-351-2640 *
******************************************************************************
* Requirements have always been the least stable part of any project I have  *
* worked upon.	                        -- Robert Martin via Usenet 12/02/95 *
******************************************************************************

[ To submit articles: Try just posting with your newsreader.
		      If that fails, use mailto:std-c++@ncar.ucar.edu
  FAQ:    http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID: <4glcfq$sfr@venus.roc.csci.csc.com>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: tottinge@csci.csc.com (Tim Ottinger)
Newsgroups: comp.std.c++
Subject: OSTRSTREAM and sizing
Date: 23 Feb 1996 23:27:35 GMT
Organization: CSC CIS - TRIS DIVISION
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4glcfq$sfr@venus.roc.csci.csc.com>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
Summary: How to determine size of strbuffer?
X-Nntp-Posting-Host: pccom9-156.csci.csc.com
X-Newsreader: News Xpress Version 1.0 Beta #3
Content-Length: 1669
X-Lines: 45
Originator: clamage@taumet