hello, I wrote a simple logger, which should print last error through win32 Api function GetLastError. However, logger itself creates the last error and false feed back caused me a day.
_file.open("log.txt", std::fstream::out | std::fstream::trunc); this line generate ERROR_ALREADY_EXISTS log.txt is already exist, yes it does exist, I just want to override the actual one.
_file.open("log.txt", ios::app); this line is another problem, I just want to open the existing file and append to new text to it but this line generates the same error.
How can I do these operations without getting error ?
ERROR_ALREADY_EXISTS is not an error at all! Check out the CreateFile() function's documentation, which I guess is ultimately called by the C++ runtime under Windows (this is Windows, right?).