* iostream bug ?
@ 2003-01-30 13:34 Gregoire Banderet
0 siblings, 0 replies; only message in thread
From: Gregoire Banderet @ 2003-01-30 13:34 UTC (permalink / raw)
> uname -mrpsv
OSF1 V4.0 1530 alpha
> cat stream.cxx
#include <iostream>
#include <sstream>
int main(int NbArgs, char *pszArgs[])
{
std::ostringstream ostrs;
std::string strIn = "This is a string of 129
bytes....................................................................................................";
//std::string strIn = "This is a string of 128
bytes...................................................................................................";
#ifdef WORKAROUND // we write the string per blocks of 128 bytes.
long NbBytesWritten = 0;
long NbBytesToWrite = strIn.length();
long const NbBytesMax = 128;
std::string strInLocalCopy = strIn;
std::ostream &os = ostrs;
while (NbBytesWritten < strIn.length())
{
NbBytesToWrite = NbBytesToWrite > NbBytesMax ? NbBytesMax :
NbBytesToWrite;
os.write(strInLocalCopy.c_str(), NbBytesToWrite);
strInLocalCopy.erase(0, NbBytesToWrite);
NbBytesWritten += NbBytesToWrite;
NbBytesToWrite = strIn.length() - NbBytesWritten;
}
#else // !WORKAROUND
ostrs << strIn;
ostrs.flush();
#endif // WORKAROUND
std::cout << ostrs.str() << std::endl;
}
> cxx -w0 -D__USE_STD_IOSTREAM stream.cxx -o stream
> ./stream
> cxx -w0 -D__USE_STD_IOSTREAM -DWORKAROUND stream.cxx -o stream
> ./stream
This is a string of 129
bytes....................................................................................................
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-01-30 13:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-30 13:34 iostream bug ? Gregoire Banderet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox