Author Topic: File creation problem...  (Read 5328 times)

Samster33

  • Guest
File creation problem...
« on: October 16, 2005, 11:41:04 pm »
Hi everyone.

I'm not sure why but the following code:
Code
void CFile::initFile()
{
numRecords=0;
DataFile.open("GameData.dat", ios::in | ios::binary);
    DataFile.seekg(0L,ios::beg);
DataFile.read((char *)&numRecords,sizeof(int));
DataFile.close();
if(!numRecords)
{

DataFile.open("GameData.dat", ios::out | ios::binary);
DataFile.clear();
DataFile.seekp(0L,ios::beg);
DataFile.write((char *) &numRecords,sizeof(int));
DataFile.close();

}
DataFile.open("GameData.dat",ios::in|ios::out|ios::binary);
};
 

Does not seem to create a GameData.dat file when it is called.  This only happens when I am using CodeBlocks to compile and run the project.  using MinGW g++ from the console with this : 'g++ main.cpp functions.cpp -o Game.exe' and then run Game.exe it creates the GameData file no problem.  MSVC 6 also compiles and runs the Program which creates a GameData.dat file. 

Apparently CodeBlocks is not configured properly or something?   I am using CodeBlocks RC-1.  I downloaded and setup MinGW 3.4.4 separtely and then had CodeBlocks auto detect it.

My operating system is Windows XP if that helps.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: File creation problem...
« Reply #1 on: October 17, 2005, 12:07:07 am »
The problem could be the file is being created somewhere else in your HDD. Try searching for that file in your HDD, but before that try in the Code::Blocks installation folder and see if it was created there.

Samster33

  • Guest
Re: File creation problem...
« Reply #2 on: October 17, 2005, 12:19:19 am »
Aye,

Good thinking Ceniza.  The file is being created somewhere else. 

Thanks a bunch!