Click here to Skip to main content
15,923,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert CString to const char * [modified] Pin
Cedric Moonen21-Oct-08 0:55
Cedric Moonen21-Oct-08 0:55 
RantRe: Convert CString to const char * PinPopular
toxcct21-Oct-08 1:26
toxcct21-Oct-08 1:26 
AnswerRe: Convert CString to const char * Pin
Cedric Moonen21-Oct-08 0:19
Cedric Moonen21-Oct-08 0:19 
GeneralRe: Convert CString to const char * Pin
SandipG 21-Oct-08 1:08
SandipG 21-Oct-08 1:08 
GeneralRe: Convert CString to const char * Pin
dehseth21-Oct-08 1:42
dehseth21-Oct-08 1:42 
AnswerRe: Convert CString to const char * Pin
Le@rner21-Oct-08 1:55
Le@rner21-Oct-08 1:55 
GeneralRe: Convert CString to const char * Pin
toxcct21-Oct-08 2:00
toxcct21-Oct-08 2:00 
GeneralRe: Convert CString to const char * Pin
Cedric Moonen21-Oct-08 2:04
Cedric Moonen21-Oct-08 2:04 
"_$h@nky_" wrote:
1.
CString MyString = "ABCDEF";
char * szMyString = (char *) (LPCTSTR) MyString;


This is wrong: if UNICODE is not defined, you don't need any casts. If UNICODE is defined, the results will be completely wrong. Please read the article from Michael Dunn (see one of my previous replies) before answering such questions.


"_$h@nky_" wrote:
2.
char *pBuffer = new char[1024];
CString strBuf = "Test";
pBuffer = strBuf.GetBuffer(sizeof(pBuffer));


This is plainly wrong too, see the other replies.

Please read the previous answers before posting !

Cédric Moonen
Software developer

Charting control [v1.5]
OpenGL game tutorial in C++

QuestionRe: Convert CString to const char * Pin
CPallini21-Oct-08 2:40
mveCPallini21-Oct-08 2:40 
AnswerRe: Convert CString to const char * Pin
Mark Salsbery21-Oct-08 5:03
Mark Salsbery21-Oct-08 5:03 
AnswerRe: Convert CString to const char * Pin
Alan Balkany21-Oct-08 4:04
Alan Balkany21-Oct-08 4:04 
NewsRe: Convert CString to const char * Pin
Roger Stoltz21-Oct-08 5:53
Roger Stoltz21-Oct-08 5:53 
QuestionWindows Firewall exception Pin
Krishnakumartg20-Oct-08 23:55
Krishnakumartg20-Oct-08 23:55 
AnswerRe: Windows Firewall exception Pin
Saurabh.Garg21-Oct-08 1:18
Saurabh.Garg21-Oct-08 1:18 
AnswerRe: Windows Firewall exception Pin
User 21559721-Oct-08 1:35
User 21559721-Oct-08 1:35 
QuestionCOM dll registration Pin
Krishnakumartg20-Oct-08 23:44
Krishnakumartg20-Oct-08 23:44 
AnswerRe: COM dll registration Pin
Iain Clarke, Warrior Programmer21-Oct-08 0:05
Iain Clarke, Warrior Programmer21-Oct-08 0:05 
GeneralRe: COM dll registration Pin
Krishnakumartg21-Oct-08 0:26
Krishnakumartg21-Oct-08 0:26 
AnswerRe: COM dll registration Pin
Roger Stoltz21-Oct-08 0:16
Roger Stoltz21-Oct-08 0:16 
GeneralRe: COM dll registration Pin
Krishnakumartg21-Oct-08 0:28
Krishnakumartg21-Oct-08 0:28 
GeneralRe: COM dll registration Pin
Iain Clarke, Warrior Programmer21-Oct-08 1:05
Iain Clarke, Warrior Programmer21-Oct-08 1:05 
AnswerRe: COM dll registration Pin
Roger Stoltz21-Oct-08 2:13
Roger Stoltz21-Oct-08 2:13 
QuestionInterface not registered Pin
CodingLover20-Oct-08 23:36
CodingLover20-Oct-08 23:36 
AnswerRe: Interface not registered Pin
Iain Clarke, Warrior Programmer21-Oct-08 0:07
Iain Clarke, Warrior Programmer21-Oct-08 0:07 
QuestionRe: Interface not registered Pin
Roger Stoltz21-Oct-08 0:10
Roger Stoltz21-Oct-08 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.