5

I have one binary file which I have created. In it, data is stored in binary form but I will show it in human readable form like ;

 [someOtherData]6759A_block$[someOtherData]

I hold that data "6759A_block$" in temp_S, which is declared as string. Now, I want split first 3 byte away from temp_S, and then store it in unsigned int. To accomplish my wish, I have write below code segment;

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

However, when I compile my small program, it gives an error shown below ;

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

My questions are :

  • What is the meaning of this compiler error ?
  • how can I fix that problem, and take first three byte of data to unsigned int ?

EDIT :

  • platform linux
  • g++
  • i didn't get any error using this code. Can you specify your compiler? – dip Nov 11 '11 at 09:34
  • possible duplicate of [C++ compile error: has initializer but incomplete type](http://stackoverflow.com/questions/13428164/c-compile-error-has-initializer-but-incomplete-type) – ani627 Mar 23 '15 at 09:53

1 Answers1

15

GCC gives that error when you forget this:

#include <sstream> //this is where istringstream is defined
Nawaz
  • 353,942
  • 115
  • 666
  • 851