使用istringstream给出错误|原因

Using istringstream gives error | Why

本文关键字:原因 错误 出错 istringstream 使用      更新时间:2023-10-16

我已经创建了一个二进制文件。其中,数据以二进制形式存储但我将以人类可读的形式显示,如;

 [someOtherData]6759A_block$[someOtherData]

我将数据"6759A_block$"保存在temp_S中,它被声明为string。现在,我想从temp_S中拆分前3个字节,然后将其存储在unsigned int中。为了实现我的愿望,我写了下面的代码段;

 unsigned int number;
 { 
 string tmp ( temp_S , 0  ,3 ); 
 istringstream temp_Istream ( tmp ) ;
 temp_Istream >> number;
 }

然而,当我编译我的小程序时,它给出了如下所示的错误;

error: variable ‘std::istringstream temp_S’ has initializer but incomplete type

我的问题是:

    这个编译错误是什么意思?
  • 如何解决这个问题,并采取前三个字节的数据unsigned int ?
编辑:

    <
  • 平台linux/gh>
  • g++

当您忘记这个时,GCC会给出错误:

#include <sstream> //this is where istringstream is defined
相关文章: