If I run this method I get this access violation exception (Is being thrown at the file.open() call):Code:std::string Program::readFile(const char* path) { //Variables. std::ifstream file; std::string content; //Set exception mask for file stream. file.exceptions(std::ifstream::failbit | std::ifstream::badbit); //Try to read the file. try { //Open the file. file.open("test.txt"); //Read the content. file >> content; //Close the file. file.close(); //Return the content. return content; } //Something went wrong. catch (std::ifstream::failure e) { std::cout << "[Read Error]: " << path << " => " << e.what() << std::endl; } return NULL; }
The exception is in the file xstring at these lines:Code:Exception thrown at 0x00007FFD4C42FCB1 (ucrtbased.dll) in LearnOpenGL.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Capture.jpgCode:#else // _HAS_CXX17 return _CSTD strlen(reinterpret_cast<const char*>(_First)); #endif // _HAS_CXX17
Tnank you!





Reply With Quote
