Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > a question about ostringstream

Reply
Thread Tools

a question about ostringstream

 
 
Aman JIANG
Guest
Posts: n/a
 
      09-18-2007
hello, i am a beginner to stringstream.

int main()
{
ostringstream oss;
for (int i = 0; i < 100; i++) {
oss << "word " << endl;
cout << oss.tellp() << " ";
}
}

0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

why the result of ostringstream::tellp() is always zero ?

but ofstream::tellp() works well:

int main()
{
ofstream ofs("test.txt");
for (int i = 0; i < 100; i++) {
ofs << "word " << endl;
cout << ofs.tellp() << " ";
}
}

please 'tell' me why

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
memory allocation question when using ostringstream in STL sylcheung@gmail.com C++ 6 01-10-2006 10:10 PM
Re: ? How to clear ostringstream buffer Mark Warren C++ 3 07-23-2003 10:12 AM
vector of ostringstream Alex Vinokur C++ 4 07-14-2003 02:36 AM
Re: std::ostringstream unexpected behavior with .net 2003. Russell Hanneken C++ 0 06-25-2003 10:22 PM
Re: std::ostringstream unexpected behavior with .net 2003. Victor Bazarov C++ 0 06-25-2003 10:20 PM



Advertisments