In a program I am writing, the one line of declaring an ifstream object causes the program to "crash" and a non-zero return code to be returned. Instead of pasting the full program here, I'll paste a sample program that "crashes" just the same.
I put "crash" in quotations because the program will run to completion, but I will get an error message in Vista saying "your program has stopped working" and the program will return a non-zero error. In XP, I don't get the pop-up message, but I do get the non-zero number returned. It's the same non-zero return code each time, but I haven't figured out what it means.
First, some background info:
OS this happens in: Vista and XP
IDE being used: Codeblocks 8.02
Compilers tried: GCC and Borland
Main returns: -1073741819
Second, here is the program that fails with the aforementioned error:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream inFile;
cout << "Hello world!" << endl;
return 0;
}
In the console, I get:
Hello world!
Process returned -1073741819 (0xC0000005) execution time : 4.137 s
Press any key to continue.
If I remove the ifstream declaration, I get:
Hello world!
Process returned 0 (0x0) execution time : 0.051 s
Press any key to continue.