This topic is 5411 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

When I run the check_If_Tga theres no problem, but then after that when I run read_Tga_File it doesn't but anything in m_tgaFileHeader. But if I skip the first function it puts the correct data in m_tgaFileHeader but one byte backwards.
bool CTga::check_If_Tga()
{
char Str[17];
// Go to the TRUEVISION-XFILE start bit.
// And put the next 16 bits in str.
m_file.seekg( -18, ios_base::end );
m_file.getline(Str, 17);

// If the 16bits are "TRUEVISION-XFILE" then return true.
if( !strcmp(Str, "TRUEVISION-XFILE"))
return true;
else
return false;
}

{
m_file.seekg( 0, ios_base::beg);
}



Share on other sites
The file is being placed in an error state after the check_If_Tga function runs because of eof. Call m_File.clear() before trying to read again.

Two other things, one, I'm not sure that the parameter is supposed to be negative. I think it might be a positive number when its ios::end. Two, you should use read rather than getline. I'm not too familiar with text mode files but that reads until it reaches a carriage return.

Share on other sites
The parameter should be negative otherwise it won't work.. :-)

• 21
• 16
• 9
• 17
• 13