#include <strstream>
#include <iostream>
using namespace std;
void main()
{
strstream ss;
ss << "hello" << ends;
cout << ss.str() << endl;
ss.seekp(0, ios::beg);
ss << "ok" << ends;
cout << ss.str() << endl;
}在vc下编译运行,
结果如下:
Hello
Hello
请问为什么不是
ok
#include <iostream>
using namespace std;
void main()
{
strstream ss;
ss << "hello" << ends;
cout << ss.str() << endl;
ss.seekp(0, ios::beg);
ss << "ok" << ends;
cout << ss.str() << endl;
}在vc下编译运行,
结果如下:
Hello
Hello
请问为什么不是
ok
BUFFER冻结,也就是ss << "ok" << ends;不起作用了,所以结果是
Hello
Hello
调用 rdbuf->freeze( 0 ).去解冻该BUFFER。
那在什么情况下Buffer不会被冻结?
冻结有什么意义?
更详细的内容请查看MSDN。