Click here to Skip to main content
15,897,518 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: dialog box w/ image from memory Pin
RomTibi30-Nov-07 7:40
RomTibi30-Nov-07 7:40 
GeneralRe: dialog box w/ image from memory Pin
Hamid_RT30-Nov-07 17:48
Hamid_RT30-Nov-07 17:48 
GeneralRe: dialog box w/ image from memory Pin
RomTibi4-Dec-07 9:05
RomTibi4-Dec-07 9:05 
AnswerRe: dialog box w/ image from memory Pin
Lord Kixdemp29-Nov-07 21:16
Lord Kixdemp29-Nov-07 21:16 
GeneralRe: dialog box w/ image from memory Pin
RomTibi30-Nov-07 7:43
RomTibi30-Nov-07 7:43 
Questionconvert CString in char* gives wrong ourput Pin
neha.agarwal2729-Nov-07 17:31
neha.agarwal2729-Nov-07 17:31 
AnswerRe: convert CString in char* gives wrong ourput Pin
Paresh Chitte29-Nov-07 19:06
Paresh Chitte29-Nov-07 19:06 
AnswerRe: convert CString in char* gives wrong ourput Pin
Iain Clarke, Warrior Programmer29-Nov-07 22:18
Iain Clarke, Warrior Programmer29-Nov-07 22:18 
You have two problems, I think.

1/ You are making a character pointer, but only pointing to one character. That's *1* byte of RAM. I can pretty much guarantee that your string is longer (remember it will finish with a NULL... So you will get two BYTE used, and quite likely more - so you could crash your program (if you're lucky) with string overflow. I think you're have compiled in debug mode, which will give you a little room either side of variables, which is why you're surviving this error.

2/ You are making a character pointer, but I bet your software has been compiled as UNICODE. Which means CString will be unicode too. Then you're just giving sprintf the raw CString object (not even ussing (LPCTSTR) in front of it. Frankyly, I'm surprised you don't get more than gibberish.


Answers...

If your string is not guaranteed to be US english friendly, converting it to char * is almost certainly a bad idea. What if your program was used in Korea?

If you're certain...

Look up the function WideCharToMultiByte in MSDN - and using google should be able to give you plenty of examples. If you use it with certain parameters (as described in msdn) then you can get the length of string you need to pass it. (There's a link on the msdn page to example code).

Iain.



AnswerRe: convert CString in char* gives wrong ourput Pin
SandipG 29-Nov-07 23:32
SandipG 29-Nov-07 23:32 
QuestionHOWTO: Develop an Active Document for Internet Explorer Pin
The Hoff29-Nov-07 11:38
The Hoff29-Nov-07 11:38 
QuestionWorking with an HTML document Pin
Tom Paronis29-Nov-07 11:03
Tom Paronis29-Nov-07 11:03 
AnswerRe: Working with an HTML document Pin
led mike29-Nov-07 11:34
led mike29-Nov-07 11:34 
GeneralRe: Working with an HTML document Pin
Tom Paronis30-Nov-07 9:21
Tom Paronis30-Nov-07 9:21 
AnswerRe: Working with an HTML document Pin
Hamid_RT29-Nov-07 19:07
Hamid_RT29-Nov-07 19:07 
GeneralRe: Working with an HTML document Pin
Tom Paronis30-Nov-07 9:24
Tom Paronis30-Nov-07 9:24 
GeneralRe: Working with an HTML document Pin
Hamid_RT30-Nov-07 20:31
Hamid_RT30-Nov-07 20:31 
QuestionNeed help, last part of C++ design... Pin
EvilRyu50029-Nov-07 10:01
EvilRyu50029-Nov-07 10:01 
QuestionRe: Need help, last part of C++ design... Pin
David Crow29-Nov-07 11:48
David Crow29-Nov-07 11:48 
AnswerRe: Need help, last part of C++ design... Pin
Hamid_RT29-Nov-07 18:56
Hamid_RT29-Nov-07 18:56 
AnswerRe: Need help, last part of C++ design... Pin
Nelek29-Nov-07 23:51
protectorNelek29-Nov-07 23:51 
AnswerRe: Need help, last part of C++ design... Pin
Iain Clarke, Warrior Programmer29-Nov-07 23:56
Iain Clarke, Warrior Programmer29-Nov-07 23:56 
QuestionSockets. Compatibility with fcntl function Pin
DrBratak29-Nov-07 8:31
DrBratak29-Nov-07 8:31 
AnswerRe: Sockets. Compatibility with fcntl function Pin
JudyL_MD29-Nov-07 10:17
JudyL_MD29-Nov-07 10:17 
QuestionWhich Function is better.? [modified] Pin
Schehaider_Aymen29-Nov-07 6:59
Schehaider_Aymen29-Nov-07 6:59 
AnswerRe: Which Function is better.? Pin
krmed29-Nov-07 10:06
krmed29-Nov-07 10:06 

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.