little trouble with getline
hi,
Cant seem to figure out why its returning NULL on getline everytime it iterates when the file (a .obj) does contain data on its lines.
the reading function is:
Code:
void Loader::Complete_Read() {
string data = "";
bool cont = true;
if(fin.is_open()) //If file is open
{
while(cont) //While not finished
{
if(!(getline(fin, data) == NULL)) //is it EOF
{
if(!Skip_Line(data)) //is it White line or Skip line
{
Set_Data(data); // data handled elsewhere
}
}
else {
Console_Message(0);
if(fin.is_open()) {
try {
fin.close();
cerr << "Closed File safely" << endl;
}
catch(...) {Console_Message(2); exit(-1);}
}
cont = false;
}
}
}
else
{
Console_Message(1);
exit(-1);
}
}
data in .obj example is
####
#
# OBJ File Generated by LightWave3D
# LightWave3D OBJ Export v2.2
#
####
# Object: 1
#
# Vertices: 12
# Points: 0
# Lines: 0
# Faces: 7
# Materials: 1
#
####
o 1
# Vertex list
v -0.539683 0 0.031746
v 0.52381 0 0.031746
etc.
Any help as to what im doing wrong would be great, thankyou :(