C++Builder program does not run (but if I delete file.close() line it does!)

308 Views Asked by At

I'm developing my first game application since this winter, and now I meet one very strange problem.

Using Embarcadero C++ Builder XE my app always normally compiled and ran, but today it fails to start, but still compiled successfully!
I just press "Run" as usual, see console output "Success Elapsed time etc" and then - nothing. My app's window just does not appear.

I figured out that the problem is in this code:

ifstream file;
file.open(fileWithTextureProp, ios::binary);

int length;
char * buffer;
// get length of file:
file.seekg (0, ios::end);
length = file.tellg();
file.seekg (0, ios::beg);

// allocate memory:
buffer = new char [length+1];
buffer[length] = '\0';

// read data as a block:
file.read (buffer,length);

xml_document<> doc;
doc.parse<0>(buffer);

/*
 some xml parsing here, if I delete or comment this - nothing changes
   */

delete[] buffer;

file.close(); // NOTE: if I comment this line - program properly starts (!)

What am I doing wrong?

0

There are 0 best solutions below