So I'm trying to read in from a file. And if there is a '#' in the middle of a line, or anywhere for that matter, I want to ignore the rest of the line, and keep reading. This is what I have:
while(getline(pgmFile, temp))
{
istringstream readIn(temp);
lines++;
while(readIn >> convert)
{
//cout << temp[counter] << endl;
if (temp.length() == 0 || temp[counter] == '#' || temp[counter] == '\r' || temp[counter] == '\n')
{}
else
{/*cout << temp << endl;*/}
if(temp.at(counter) == '\n' || temp.at(counter) == '\r')
{}
if(convert < 57 || convert > 40)
{
pixels.push_back(convert);
}
}
For this input file:
P5
4 2
64
0 0 0 0 # don't read these: 1 1 1 1
0 0 0 0
It should read in the 0's, but nothing after the #.
temp is of type "string", and it's reading in line by line.
Any help is much appreciated!!!