Question

Need to log the content of buf using the LogMethod() below the problem is that LogMethos only accepts a "Const CString&"

char buf[1024];
strcpy(buf, cErrorMsg);

// need to pass to LogMethod "buf" how do i do that?
log.LogMethod(const CString &); 

Thans Rev

Reversed

Was it helpful?

Solution

If you're talking about MFC CString, as far as I can tell, it should have a non-explicit constructor taking TCHAR const *. In other words, the following should work.

log.LogMethod(buf); 

If it doesn't, please post the error message.

OTHER TIPS

log.LogMethod(CString(buf));

This will avoid the problem where the compiler won't automatically create the CString object using the appropriate constructor since the argument is a reference (It would have if the argument was a "plain" CString).

CString cs;
cs = buf;

log.LogMethod(cs)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top