Mail Archives: djgpp/1998/05/02/23:21:52
Hi All,
Allegro seems to be choking whenever I try to use an ifstream object.
In the following code, "numtiles" exists within the Game object (its an
'int'). The program runs until you get to the line:
file >> numtiles;
Where it dies a brutal death and GPF's. The file exists, the variable
is valid, the a_filename is perfectly fine and filename is allocated
properly with the appropraite file path. This sucks because we have
another method exactly the same that works perfectly fine (all
deallocation is done).
Any thoughts?
Chris
/* loadTileDefinitions:
Loads all tile definitions from disk and builds the maps tile list.
*/
void Game::loadTileDefinitions (char * a_filename)
{
// local variables
ifstream file;
char *filename;
// grab a new copy of filename
filename = strdup(a_filename);
filename = strcat(filename, ".til");
if (!filename) Error::error ("File Name Could Not Be Allocated");
// open file
file.open(filename, ios::in);
if (!file) Error::error ("Tile Definition Could Not Be Opened");
// read in the number of tiles
file >> numtiles;
// close file and delete char *
file.close();
delete filename;
} //loadTileDefinitions
--
------------------------------------------------------------------
Christopher Lambert chrislambert AT pobox DOT com, infostorm AT pobox DOT com
INFOSTORM Software Development and Consulting Services
Software Developer CPA, Java Programmer 1.1 Certified
------------------------------------------------------------------
- Raw text -