News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

File creation problem...

Started by Samster33, October 16, 2005, 11:41:04 PM

Previous topic - Next topic

Samster33

Hi everyone.

I'm not sure why but the following 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.

Ceniza

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

Aye,

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

Thanks a bunch!