The Method readFile should read all chars of the file into a string and return it. After opening it, the open status will be printed to the console. When i am compiling a Debug-Build, the returned string matches the content of the file. But when i am compiling a Release-Build, the line with getline throws an Debug Assertion fail and shows a popup with the following text:
Debug Assertion Failed!
File: minkernel\crts\ucrt\src\appcrt\lowio\read.cpp
Expression: _osfile(fh) & FOPEN
CODE:
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
string readFile(const string& fileName) {
cout << '\'' << fileName << '\'' << endl;
ifstream file{ fileName };
cout << file.is_open() << endl;
string str;
string content;
cout << "START" << endl;
while (getline(file, str)) {
cout << "READ" << endl;
content += str;
content.push_back('\n');
}
file.close();
return content;
}