Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionCString to const char* Pin
_Flaviu29-Aug-19 22:48
_Flaviu29-Aug-19 22:48 
AnswerRe: CString to const char* Pin
Victor Nijegorodov29-Aug-19 22:55
Victor Nijegorodov29-Aug-19 22:55 
GeneralRe: CString to const char* Pin
_Flaviu29-Aug-19 23:08
_Flaviu29-Aug-19 23:08 
GeneralRe: CString to const char* Pin
_Flaviu29-Aug-19 23:31
_Flaviu29-Aug-19 23:31 
GeneralRe: CString to const char* Pin
Victor Nijegorodov29-Aug-19 23:40
Victor Nijegorodov29-Aug-19 23:40 
GeneralRe: CString to const char* Pin
_Flaviu29-Aug-19 23:56
_Flaviu29-Aug-19 23:56 
GeneralRe: CString to const char* Pin
Victor Nijegorodov30-Aug-19 0:08
Victor Nijegorodov30-Aug-19 0:08 
GeneralRe: CString to const char* Pin
_Flaviu30-Aug-19 0:17
_Flaviu30-Aug-19 0:17 
with the first try:
C++
CStringA ansiText("TestA");
LPCSTR ansi = (LPCSTR)ansiText;
TRACE("%s\n", ansi);

the result is TestA
for the second try, I got an error:
C++
1>d:\tempx\test\testdoc.cpp(53): error C2440: 'type cast' : cannot convert from 'CString' to 'LPCSTR'

at
C++
CString someText("Test");
ansi = (LPCSTR)someText;    // <-- here is the error
TRACE("%s\n", ansi);

The project is unicode.
GeneralRe: CString to const char* Pin
Victor Nijegorodov30-Aug-19 0:26
Victor Nijegorodov30-Aug-19 0:26 
GeneralRe: CString to const char* Pin
_Flaviu30-Aug-19 1:06
_Flaviu30-Aug-19 1:06 
GeneralRe: CString to const char* Pin
Richard MacCutchan30-Aug-19 2:40
mveRichard MacCutchan30-Aug-19 2:40 
QuestionRe: CString to const char* Pin
David Crow10-Sep-19 4:32
David Crow10-Sep-19 4:32 
GeneralRe: CString to const char* Pin
_Flaviu30-Aug-19 0:02
_Flaviu30-Aug-19 0:02 
GeneralRe: CString to const char* Pin
Richard MacCutchan30-Aug-19 0:57
mveRichard MacCutchan30-Aug-19 0:57 
Questioncpplinq - How to use the aggregate function - Get longest string a string array Pin
Mc_Topaz27-Aug-19 22:24
Mc_Topaz27-Aug-19 22:24 
AnswerRe: cpplinq - How to use the aggregate function - Get longest string a string array Pin
Graham Breach27-Aug-19 23:13
Graham Breach27-Aug-19 23:13 
GeneralRe: cpplinq - How to use the aggregate function - Get longest string a string array Pin
Mc_Topaz27-Aug-19 23:35
Mc_Topaz27-Aug-19 23:35 
Questionerror LNK2019 Pin
_Flaviu27-Aug-19 1:03
_Flaviu27-Aug-19 1:03 
AnswerRe: error LNK2019 Pin
Richard MacCutchan27-Aug-19 1:25
mveRichard MacCutchan27-Aug-19 1:25 
AnswerRe: error LNK2019 Pin
phil.o27-Aug-19 2:12
professionalphil.o27-Aug-19 2:12 
GeneralRe: error LNK2019 Pin
Richard MacCutchan27-Aug-19 4:31
mveRichard MacCutchan27-Aug-19 4:31 
AnswerRe: error LNK2019 Pin
Stefan_Lang29-Aug-19 21:56
Stefan_Lang29-Aug-19 21:56 
GeneralRe: error LNK2019 Pin
_Flaviu29-Aug-19 22:09
_Flaviu29-Aug-19 22:09 
Questionwarning LNK4099: PDB 'utils.pdb' was not found Pin
_Flaviu26-Aug-19 22:14
_Flaviu26-Aug-19 22:14 
AnswerRe: warning LNK4099: PDB 'utils.pdb' was not found Pin
Richard MacCutchan26-Aug-19 22:44
mveRichard MacCutchan26-Aug-19 22:44 

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.