【发布时间】:2014-08-12 05:45:54
【问题描述】:
我正在将一些数据放入从 stringstream 获得的流 buf 中
std::stringstream data;
auto buf = data.rdbuf();
buf->sputn(XXX);
我想要的是能够将一些虚拟数据放入此缓冲区,然后在以后获得正确数据后,替换虚拟数据。
以下几行:
auto count = 0;
buf->sputn((unsigned char *)&count, sizeof(count));
for (/*some condition*/)
{
// Put more data into buffer
// Keep incrementing count
}
// Put real count at the correct location
我尝试使用 pubseekpos + sputn,但它似乎没有按预期工作。任何想法可能是正确的方法吗?
【问题讨论】:
标签: c++ stringstream streambuf