I am trying to create/write a txt cfg file. It is working fine in VC++ debugger but after I generated a .exe file. It doesn't work anymore. I also tried adding in the current workpath but still doesn't work. Anyone experienced this problem before? Thanks!
BTW, the ofstream code is in a dll.
Re: ofstream not working for the released version.
Originally Posted by clonebull
I am trying to create/write a txt cfg file. It is working fine in VC++ debugger but after I generated a .exe file. It doesn't work anymore.
Please be more specific. What "doesn't work"? Is the file created? Does the code crash?
Second, you are passing something to that function -- we don't know what that name is since it is a parameter. Maybe that name is garbage in release mode.
Anytime you suspect there is something wrong with file writing, take a step back and hard-code the file name in the code. Then see if that works. If it works, then the problem is the generation of the name, not the actual opening and closing of the file.
Re: ofstream not working for the released version.
Thanks for all the suggestions!
Problem identified.
The config file reading/writing problem was caused by incorrect path because the current working path changed by GetOpenFileName(). So actually the config file was saved to another folder.
It was hard for me to debug the dll with .exe. "printf, cout, MessageBox" doesn't work, dont know why. any suggestions?%
Bookmarks