delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/02/23:21:52

From: Christopher Lambert <chrislambert AT pobox DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Allegro: Killing ifstream?
Date: Sat, 02 May 1998 20:04:23 -0700
Organization: INFOSTORM
Lines: 53
Message-ID: <354BDEB7.AEB487DF@pobox.com>
Reply-To: chrislambert AT pobox DOT com
NNTP-Posting-Host: 209.53.30.181
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019