   File output
  I am trying to add logging to my engine, but for some reason it isn't working today.  What I did is move the code from one project to the next.  It works fine in project 1, but not project 2.Here is the implementation in the header file of Engine//Variablesstd::string filename; //Used to setup the ability to log eventsstd::ofstream fout;  //ofstream variable to output to file;bool fileJustOpened;  //Variable to detect when the file was first openedstd::string name;  //Set file name here for log fileHere is how I set it up when engine is initialized.fileJustOpened = false;name = "EngineLog.txt";filename = " ";Now here is the code for EnableLogging()void Engine::EnableLogging(){//Setting name of log filefilename = name;fileJustOpened = true;fout.open(filename.c_str());if(!fout.is_open()){::MessageBoxA(0,"Unable to open file", "Error", MB_OK);}fout.close();}Why would the messagebox appear?  I don't understand why the file will not open.  Am I doing something wrong.Thanks in advanceAdam   
  There is nothing wrong with the code that I can see so it must be a problem elsewhere. Can't really see what. Maybe:Is there already a read-only file called EngineLog.txt in the directory?Are you running the program somewhere where the default directory does not give write-access?I'd try changing name to equal a fully qualified path to somewhere you definately have write-access and make sure there isn't already a EngineLog.txt file in the directory.You've probably already tried all this though. Sorry can't be of more help.(BTW, if you do get it working, you probably want to move setting fileJustOpened to true after the MessageBox block).   ;  I don't really get your setup. Why is there name as well as filename if you just assign one to the other?Are those global variables or member variables? They probably should not be global.Maybe you created the file manually in project 1?Guess you want to delete the previous logfile if there is one?Try:fout.open(filename.c_str(), ios::trunc);If that doesn't help maybe post both the header and source files.   ;  Thanks for the help.  I'm not sure why, but I think it was something with .c_str().  I changed every fout.open("EngineLog.txt"), and it works fine.  I really don't understand the reason.  The reason I have two seperate variables is to test if the engine has been logged.  I could probably do this with a flag instead, maybe I'll tray implementing that next.   