use of strstream object of standard lib

N

News For Mohan

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 behaviour is not predictable .
Sometimes it is returning the char buffer correctly , sometimes it is
returning the char buffer and some garbage attached to it at the end.I am
initialising the ostrstream object by fill('\0') function.

Can U please suggest some solution.

I am writing the code below for reference.

tBool clClusterCheckResults::logUplinkZeroCellError(const clCluster&
corfCluster,
RBINTValOrderedVector <int> a_vZCsNotRetained)
{
bool a_bReturnValue(false);
ostrstream myBuffer;
myBuffer.fill('\0');
a_bReturnValue = true;

myBuffer << corfCluster // << opearor is overloaded for clCluster class
<< " WARNING: The Cluster has no Uplink ZeroCells. "
<< " The following Zero Cells with Cobounding OC, with Uplinks are not
retained "
<< " in the higher level. (ZC Index) - ";

for(int iZeroCellIterator = 0 ;
iZeroCellIterator < a_vZCsNotRetained.length() ;
iZeroCellIterator++)
{
myBuffer << a_vZCsNotRetained[iZeroCellIterator] << " ";
}

myBuffer << "END\n";
cout<< "``````````PRINTING mybuffer logUplinkZeroCellError`````````\n";
cout<< myBuffer.str(); //Here the output is coming errorous
cout<< "``````````OVER`````````````````````````````````````````````\n";

m_oReport.logErrorMessage(myBuffer);

m_oResultsCounter.incrementErrorCount(
corfCluster.getLevel(),
UplinkZeroCellCheck,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top