www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/10/22:17:23

From: Mike McLean <libolt AT primenet DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: code under Allegro 3.0 and PG++ 1.01
Date: 10 Feb 1998 15:41:01 -0700
Organization: Primenet Services for the Internet
Lines: 73
Message-ID: <34E0D88C.13CE83BC@primenet.com>
MIME-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I have a problem with some code I am using for file routines under
allegro 3.0.  I am writing a game in C++ using the PG++ 1.01 addition to
DJGPP.  I get undefined reference to terminate(void) and a bunch of
errors that scroll too fast for me to see.  What could be wrong with the
following 2 functions?  It works if I comment out all the code and leave
the functions blank, but then I can't save or read info from disk.  Any
help is greatly appreciated.

 
void fileSave(void)
{

  int stamina, strength, dexterity, magic, location = 0;
  characterStats charStats;
  stamina = charStats.stamina;
  strength = charStats.strength;
  dexterity = charStats.dexterity;
  magic = charStats.magic;

  ofstream saveGame ("game.sav", ios::out);

  if (!saveGame)
    {
      cerr << "File could not be opened" << endl;
      exit(1);
    }
  else
    {
      saveGame << location << endl;
      saveGame << stamina << endl;
      saveGame << strength << endl;
      saveGame << dexterity << endl;
      saveGame << magic << endl;
    }
}

void readFile(void)
{
  characterStats charStats;
  char location[5];
  char stamina[5];
  char strength[5];
  char dexterity[5];
  char magic[5];
  ifstream readGame ("game.sav", ios::in);

  if (!readGame)
    {
      cerr << "File could not be opened" << endl;
      exit(1);
    }
  else
    {
      while (readGame >> location >> stamina >> strength >> dexterity >>
magic)
       itoa(charStats.location, location, 10);
       itoa(charStats.stamina, stamina, 10);
       itoa(charStats.strength, strength, 10);
       itoa(charStats.dexterity, dexterity, 10);
       itoa(charStats.magic, magic, 10);


       textprintf(screen,font,10,10,150, location);
       textprintf(screen,font,10,20,150, stamina);
       textprintf(screen,font,10,30,150, strength);
       textprintf(screen,font,10,40,150, dexterity);
       textprintf(screen,font,10,50,150, magic);
     }
}



Mike.

- Raw text -


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