Menu

Program runs fine from DevC++, but the exeDnt

sago
2004-09-22
2012-09-26
  • sago

    sago - 2004-09-22

    I have a problem, my program compiles and runs fine from inside Dev C++ (py pressing F9 or Ctrl+F9,Ctrl+F10). But then I double click the exe file in explorer it chrashes imidiently. appears to have something to with a linked file. I have 2 cpp files and one h file. Using Dev-C++ 4.9.8.0

    Any help?

     
    • Nobody/Anonymous

      what kind of programs are they?

      console programs, or the somewhat dos like programs, will go away fast if the have no input needed.

      otherwise i would suggest you post the offending source. we can not know what will make it crash without knowing what you have written.

      obag

       
    • sago

      sago - 2004-09-23

      It's a clone of "Tetris Attack" using SDL and contains a game loop. The files are main.cpp , highscore.h and highscore.cpp

      highscore.h is included in all cpp files ( #include "highscore.h" )

      source for highscore:
      //highscore.h

      include <iostream>

      include <fstream>

      include <cstring>

      include <stdlib.h>

      using namespace std;

      const int top = 10;

      struct record
      {
      char name[30];
      int score;
      };

      class Highscore
      {
      private:
      record tabel[top];
      void writeFile();
      public:
      Highscore()
      {
      ifstream scorefile("highscore.dat", ios::binary);
      if(scorefile)
      {
      for(int i = 0; i<top; i++)
      {
      scorefile.read(tabel[i].name, sizeof(char[30]));
      scorefile.read(reinterpret_cast<char>(&tabel[i].score), sizeof(int));
      }
      }
      else
      {
      for(int i = 0; i<top; i++)
      {
      strcpy(tabel[i].name,"Poul Sander");
      tabel[i].score = 2000 - i
      100;
      }
      }
      scorefile.close();
      writeFile();
      }
      bool isHighScore(int);
      void addScore(char[],int);
      int getScoreNumber(int);
      //char* getScoreName(int);
      };

      The error only occurs if this line is in main.cpp: Highscore theTopScores = Highscore();

      If I press Ctrl+F10 in Dev-C++ I can play the game and it works fine, but then I dubble click the exe file I get: "block_attack.exe - Application Error
      The instruction at "0x00400947f" referenced memory at "0x192750c4". The memory could not be "read".
      Click on OK to terminate the program
      Click on CANCEL to debug the program"

      clicking OK closes the program
      CANCEL start VS.net2003

      I havn't really made multifile program before, but I don't understand why it only runs from Dev-C++ ...

       
    • sago

      sago - 2004-09-23

      I discovered that if I ran it in combitability mode for windows 95 it ran fine...

       
    • Jim W.

      Jim W. - 2004-09-22

      "...appears to have something to with a linked file."

      Do you get an error message from Windows? What (exactly) does it say? (Is there a DLL involved?)

      -- Jim.

       

Log in to post a comment.