Jan 8, 2013 at 2:54am UTC
I want to read a PPM file and record bytes as Glubyte* .
I should check comment lines. After checking the comment lines I get a line has two integer. I try to use stringstream but compiler says not initialized because i read string from file.
How can i read integers from non-initialized string?
Jan 8, 2013 at 8:21am UTC
It would be easier to answer if you shared this part of your code which gives the compiler error.
Jan 8, 2013 at 2:22pm UTC
Now my code is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
GLubyte* readPPM(string filename)
{
GLubyte* byteArray;
string text;
int width, height, value;
GLubyte temp;
ifstream file;
file.open(filename.c_str());
getline(file,text);
getline(file,text);
while (text.at(0)!='#' ){
getline(file,text);
}
istringstream iss(text);
iss >> width >> height;
file >> value;
// Operations
return byteArray;
}
and the output is:
in function 'GLubyte* readPPM(std::string)' :
error: variable 'std::istringstream iss' has initializer but incomplete type
Last edited on Jan 8, 2013 at 2:22pm UTC
Jan 8, 2013 at 3:01pm UTC
Have you included the stringstream header file?
#include <sstream>
Jan 8, 2013 at 9:15pm UTC
thank everybody now it works