| www.delorie.com/archives/browse.cgi | search | 
| From: | "Piotr Eljasiak" <eljasiak AT NO-SPAM DOT zt DOT gdansk DOT tpsa DOT pl> | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | strstream repositioning problem | 
| Lines: | 44 | 
| X-Priority: | 3 | 
| X-MSMail-Priority: | Normal | 
| X-Newsreader: | Microsoft Outlook Express 5.00.2417.2000 | 
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2314.1300 | 
| Message-ID: | <w%ju3.26224$X3.404951@news.tpnet.pl> | 
| Date: | Tue, 17 Aug 1999 20:55:56 GMT | 
| NNTP-Posting-Host: | 212.160.44.3 | 
| X-Complaints-To: | abuse AT tpsa DOT pl | 
| X-Trace: | news.tpnet.pl 934923356 212.160.44.3 (Tue, 17 Aug 1999 22:55:56 MET DST) | 
| NNTP-Posting-Date: | Tue, 17 Aug 1999 22:55:56 MET DST | 
| Organization: | TPNET - http://www.tpnet.pl | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
| Reply-To: | djgpp AT delorie DOT com | 
My problem regards strstream repositioning - every time I seekg()
to stored position and then write to strstream, data in strstream
is truncated. Here is my sample code:
#include <stream.h>
#include <strstream.h>
int main(int, char *[])
{
  static char text[] = "The quick brown fox jumped over the lazy dog. ";
  strstream ss;
  ss << text;
  streampos pos = ss.tellp();
  ss << text << endl;
  ss.seekp(pos);
  ss << "***";
  ss.seekp(0,ios::end);
  ss << ends;
  cout << '"' << ss.str() << '"' << endl;
  ss.freeze(0);
}
Instead of (IMHO) "The quick brown fox jumped over the lazy dog. *** quick
brown fox jumped over the lazy dog. "
the output is truncated to "The quick brown fox jumped over the lazy dog.
***".
Where is an error in the above code ?
Thanks for any help,
Piotr Eljasiak
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |