Problem in Release version in VC++

shobha_jk used Ask the Experts™
I'm having problem reading or writing CString variables in Release version. While same are working in Debug mode.
For e.g. even the simplest like, CString xxx="userid" is not working.

And also,
I have used a windows API to read the current working directory as follows:

#define _MAX_PATH   260 /* max. length of full pathname */


But this is not fetching the directory value to "dir" in release version. While the same function is working in Debug mode.

Can anybody please help me in this regard.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

1) You can try to debug Release version, read this article:

2) Once I had exactly the same problem:
CString xxx="userid";    // works in Debug, doesn't work in Release

That means your program have a bug is some other place which gives unpredictable results. This is a serious problem. In my case I find such error in other place of the program:

float fValue;
CString s;
_stscanf(s, _T("%f %f"), &fValue);

Result of additional %f in format string is that program writes float value to some unpredictable place in the memory. Debug version worked OK, and strings in Release version were completely destroyed.

Other error with the same function, and again, affected only on Release build:

char c;
CString s;
_stscanf(s, _T("%d"), &c);

In this case I pass pointer to character, and scanf writes integer by this address, destroying some other data.

Obviously, in your case this may be other bug, it can be anywhere. scanf is only one of candidates to be the source of the problem.

1) Do a clean all.
2) Remove any .pch files in your temp folders
3) Do a rebuild all.

4) If you are using your own dlls, check whether you are managing resource handles properly.


Actually when the values are viewed while stepping through the program in release mode, they showed some junk values. But when messageboxes were used to view the values they looked fine. For some reasons, the variable values did not show up while stepping through the program.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial