CString::GetBuffer does not work in debug mode but in release mode 
Author Message
 CString::GetBuffer does not work in debug mode but in release mode

Hi,

has someone experienced the problem mentioned in the mail subject?

CString str;
CString id = "Something";

str.Format("%s", id);   // causes the problem, as well as
CString::operator=

The GetBuffer function calls GetData() which seems to return an unvalid
pointer.

It is very important for me to find an approach to the problem because I
must work in debug mode.

Thanks in advance
Mike



Sun, 25 May 2003 03:00:00 GMT  
 CString::GetBuffer does not work in debug mode but in release mode

Try:
CString str;
char* id = "Something";
str.Format("%s", id);

or:

CString str;
CString id = "Something";
str =  id;

or:

 CString str;
 CString id = "Something";
 str.Format("%s", (LPCTSTR)id);

Any of the ways are good for complier but the late one is stupid because
Format functions was included in CString to provide easy conversion from
null-terminated strings to CStrings. If you have 2 CStrings it is reasonable
to use assignment (option 2)

--
Regards,

GL



Sun, 25 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Program not work at release mode but work at debug mode

2. Works in Debug mode but not in Release mode

3. Code works in debug mode but not in release mode

4. MIDL compiler fails during release mode but works fine in debug mode

5. Works in Debug Mode crahses in Release Mode

6. Page fault when compile using Release mode but not Debug mode

7. Works in debug mode but not in release

8. extended stored procedure working in debug mode but not in release

9. DLL works fine in DEBUG but not in RELEASE mode

10. Run time Release mode error but no Debug mode error

11. Quiet NaNs, release mode and debug mode

12. Complining one project in release mode and another in debug mode

 

 
Powered by phpBB® Forum Software