  | | | C++ question | C++ question 2004-06-10 - By Luc-Eric Rousseau
Back I think you're confusing the "CString" in MFC with the CString in the XSI SDK. Then again, the context wasn't explicitly specified. -- --Original Message-- -- From: owner-xsi@(protected) [mailto:owner-xsi@(protected)]On Behalf Of Sebastien Dalphond Posted At: Thursday, June 10, 2004 11:13 AM Posted To: xsi Conversation: C++ question Subject: RE: C++ question
You can simply cast the CString to a LPCTSTR
operator LPCTSTR ( ) const;
Then it can be used as a const char*, as in:
CString l_sFilename = "filename.txt";
const char* l_psFileName = (LPCTSTR)l_sFilename;
Sebastien Dalphond
__ ____ ____ _____ Sebastien Dalphond R&D-Hybride
-- --Original Message-- -- From: owner-xsi@(protected) [mailto:owner-xsi@(protected)]On Behalf Of Helge Mathee Sent: Thursday, June 10, 2004 9:58 AM To: XSI@(protected) Subject: C++ question
Maybe I am dumb..... how to convert a CString to a const char *? I need this to read files inside of a c++ operator... really weird... just doesn't work... thanks, helge
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859 (See http://iso-8859.ora-code.com)-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=#ffffff> <DIV><SPAN class=035500118-10062004><FONT face=Arial color=#800000 size=2>I think you're confusing the "CString" in MFC</FONT></SPAN></DIV> <DIV><SPAN class=035500118-10062004><FONT face=Arial color=#800000 size=2>with the CString in the XSI SDK.</FONT></SPAN></DIV> <DIV><SPAN class=035500118-10062004><FONT face=Arial color=#800000 size=2>Then again, the context wasn't explicitly specified.</FONT></SPAN></DIV> <DIV><SPAN class=035500118-10062004><FONT face=Arial color=#800000 size=2></FONT></SPAN> </DIV> <DIV><SPAN class=035500118-10062004><FONT face=Arial color=#800000 size=2></FONT></SPAN> </DIV> <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma size=2>-- --Original Message-- --<BR><B>From:</B> owner-xsi@(protected) [mailto:owner-xsi@(protected)]<B>On Behalf Of </B>Sebastien Dalphond<BR><B>Posted At:</B> Thursday, June 10, 2004 11:13 AM<BR><B>Posted To:</B> xsi<BR><B>Conversation:</B> C++ question<BR><B>Subject:</B> RE: C++ question<BR><BR></FONT></DIV> <DIV><SPAN class=299370715-10062004><FONT face=Arial color=#0000ff size=2>You can simply cast the CString to a LPCTSTR</FONT> <P><FONT face=Arial><FONT color=#0000ff><FONT size=2><B>operator</B> <B>LPCTSTR</B> <B>(</B> <B>)</B> <B>const;</B></FONT></FONT></FONT></P> <P><SPAN class=299370715-10062004><FONT face=Arial color=#0000ff size=2>Then it can be used as a const char*, as in:</FONT></SPAN></P> <P><SPAN class=299370715-10062004><FONT face=Arial color=#0000ff size=2>CString l_sFilename = "filename.txt";</FONT></SPAN></P> <P><SPAN class=299370715-10062004><FONT face=Arial color=#0000ff size=2>const char* l_psFileName = (LPCTSTR)l_sFilename;</FONT></SPAN></P> <P><SPAN class=299370715-10062004><FONT face=Arial color=#0000ff size=2>Sebastien Dalphond</FONT></SPAN></P><SPAN class=299370715-10062004> <P><FONT size=2>__ ____ ____ _____<BR>Sebastien Dalphond<BR>R&D-Hybride </FONT></P></SPAN></SPAN><FONT face=Tahoma size=2>-- --Original Message-- --<BR><B>From:</B> owner-xsi@(protected) [mailto:owner-xsi@(protected)]<B>On Behalf Of </B>Helge Mathee<BR><B>Sent:</B > Thursday, June 10, 2004 9:58 AM<BR><B>To:</B> XSI@(protected)<BR><B>Subject:</B> C++ question<BR><BR></FONT></DIV> <BLOCKQUOTE dir=ltr style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px"> <DIV><FONT face=Arial size=2>Maybe I am dumb.....</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>how to convert a CString to a const char *?</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>I need this to read files inside of a c++ operator...</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>really weird... just doesn't work...</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>thanks,</FONT></DIV> <DIV><FONT face=Arial size=2></FONT> </DIV> <DIV><FONT face=Arial size=2>helge</FONT></DIV></BLOCKQUOTE></BODY></HTML>
|
|
 |