OStringStream

D

Dhruv

Hello All,

I have the following code:

***************************************

int numb=1;
std::eek:stringstream o;
o << "1-";
for(i=0;i<1000;i++)
{
o << num;
s = o.str();
num++;
cout << s << endl;

}

***************************************

So as num increments, I want the output as follows:
1-1
1-2
1-3
1-4
1-5...........

For this, I need to initialize ostringstream o to "1-" everytime.

Please help me out with this.

Thanks n Regds,
Bhavesh
 
J

John Harrison

Dhruv said:
Hello All,

I have the following code:

***************************************

int numb=1;
std::eek:stringstream o;
o << "1-";
for(i=0;i<1000;i++)
{
o << num;
s = o.str();
num++;
cout << s << endl;

}

***************************************

So as num increments, I want the output as follows:
1-1
1-2
1-3
1-4
1-5...........

For this, I need to initialize ostringstream o to "1-" everytime.

Please help me out with this.

Thanks n Regds,
Bhavesh

for(i=0;i<1000;i++)
{
std::eek:stringstream o;
o << "1-" << num;
s = o.str();
num++;
cout << s << endl;
}

john
 
A

Anand

Dhruv said:
Hello All,

I have the following code:

***************************************

int numb=1;
std::eek:stringstream o;
o << "1-";
for(i=0;i<1000;i++)
{ seekp(2);
o << num;
s = o.str();
num++;
cout << s << endl;

}

***************************************

So as num increments, I want the output as follows:
1-1
1-2
1-3
1-4
1-5...........

For this, I need to initialize ostringstream o to "1-" everytime.

Please help me out with this.

Thanks n Regds,
Bhavesh
 

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

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top