I'm trying to read characters from file but i receive a segmentation fault when i have variables declared outside main. If i delete them and try to read from file, everything works smooth. I am using dev c++ 5.7.1 with mingw 4.8.1 the portable version.
I've isolated the problem to just having a few variables declared and the file reading code. This piece of code comes from a bigger app that i am trying to develop(i am learning game development on my own).
#include <iostream>    
#include <fstream>    
bool running = true;  
bool musicPlaying = true;  
bool read = false;  
int levelNumber;  
int barWidth = 40;  
int barHeight = 10;  
float timeElapsed;  
int main(int argc, char** argv) {    
    std::ifstream file;
    file.open("test.txt");
    std::cout<<file.is_open()<<std::endl;
    char c;
    while(!file.eof()){  
        file.get(c);  
        std::cout<<c;  
    }  
    return 0;  
}
I get the output: 1, the file is open. But no character is read from file. Debug information
Why is this happening?
 
    