【发布时间】:2009-03-01 20:19:26
【问题描述】:
我想实现以下有一个字符缓冲区,我尝试移植的代码将此字符缓冲区放入流中,然后像这样进行获取
char *buffer; //this is initialized
int bufferSize; //this is initlized
std::istringstream inputStream (std::string(buffer, bufferSize));
int getVal = inputStream.get();
编辑:上面的代码是最优的吗,其中对于 getVal,您将整个缓冲区复制到流中,然后在流上执行获取操作。
如何从缓冲区本身获取 getVal 值。
【问题讨论】: