Click here to Skip to main content
15,910,121 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Unpack Files to memory and then run them (like thinstall) Pin
Nemok26-Oct-05 7:23
Nemok26-Oct-05 7:23 
QuestionRe: Unpack Files to memory and then run them (like thinstall) Pin
David Crow26-Oct-05 8:20
David Crow26-Oct-05 8:20 
AnswerRe: Unpack Files to memory and then run them (like thinstall) Pin
Nemok27-Oct-05 9:38
Nemok27-Oct-05 9:38 
AnswerRe: Unpack Files to memory and then run them (like thinstall) Pin
Chris Losinger26-Oct-05 8:24
professionalChris Losinger26-Oct-05 8:24 
AnswerRe: Unpack Files to memory and then run them (like thinstall) Pin
BadKarma26-Oct-05 8:49
BadKarma26-Oct-05 8:49 
GeneralRe: Unpack Files to memory and then run them (like thinstall) Pin
Nemok27-Oct-05 9:34
Nemok27-Oct-05 9:34 
AnswerRe: Unpack Files to memory and then run them (like thinstall) Pin
Joel Lucsy27-Oct-05 14:54
Joel Lucsy27-Oct-05 14:54 
Questionconst_cast problem?? Pin
Bob Stanneveld26-Oct-05 6:04
Bob Stanneveld26-Oct-05 6:04 
Hello,

I've encountered a strange problem when I use the const_cast() operator. See the following code that behaves strange:
std::stringstream sstrMsg;

// bla bla bla

char* pszMsg = const_cast<char*>(sstrMsg.str().c_str());
SPrintBuffer(&pszMsg);


I've checked the return values of both stringstream::str() and std::string::c_str(). They both return the expected data. Strangely enough, after the cast, pszMsg points to some undefined memory address. (The address pointed to holds the value -18).

I'm currently using the following workaround:
char* pszMsg = new char[sstrMsg.str().length()];
strncpy(pszMsg, sstrMsg.str().c_str(), sstrMsg.str().length());
SPrintBuffer(&pszMsg);
delete[] pszMsg;


Does anybody have a clue why const_cast is producing undesired results?

Behind every great black man...
            ... is the police. - Conspiracy brother


Blog[^]
AnswerRe: const_cast problem?? Pin
BadKarma26-Oct-05 8:16
BadKarma26-Oct-05 8:16 
GeneralRe: const_cast problem?? Pin
Bob Stanneveld28-Oct-05 7:01
Bob Stanneveld28-Oct-05 7:01 
AnswerRe: const_cast problem?? Pin
John R. Shaw26-Oct-05 14:59
John R. Shaw26-Oct-05 14:59 
GeneralRe: const_cast problem?? Pin
Bob Stanneveld28-Oct-05 6:56
Bob Stanneveld28-Oct-05 6:56 
GeneralRe: const_cast problem?? Pin
John R. Shaw30-Oct-05 16:28
John R. Shaw30-Oct-05 16:28 
GeneralRe: const_cast problem?? Pin
Bob Stanneveld30-Oct-05 18:51
Bob Stanneveld30-Oct-05 18:51 
QuestionLooking for GUI simple tutorial with VC++ .NET version 7.1 Pin
Loc Milkyway26-Oct-05 5:52
Loc Milkyway26-Oct-05 5:52 
AnswerRe: Looking for GUI simple tutorial with VC++ .NET version 7.1 Pin
Kevin McFarlane26-Oct-05 9:34
Kevin McFarlane26-Oct-05 9:34 
GeneralRe: Looking for GUI simple tutorial with VC++ .NET version 7.1 Pin
Loc Milkyway27-Oct-05 4:26
Loc Milkyway27-Oct-05 4:26 
QuestionOnPaint vr. DrawItem Pin
jason9926-Oct-05 5:39
jason9926-Oct-05 5:39 
AnswerRe: OnPaint vr. DrawItem Pin
Chris Losinger26-Oct-05 5:53
professionalChris Losinger26-Oct-05 5:53 
GeneralRe: OnPaint vr. DrawItem Pin
PJ Arends26-Oct-05 9:27
professionalPJ Arends26-Oct-05 9:27 
GeneralRe: OnPaint vr. DrawItem Pin
Chris Losinger26-Oct-05 9:35
professionalChris Losinger26-Oct-05 9:35 
Questionprint blank pages Pin
valerie9926-Oct-05 5:16
valerie9926-Oct-05 5:16 
Questiontoolbar for Outlook Express Pin
Anonymous26-Oct-05 4:30
Anonymous26-Oct-05 4:30 
AnswerRe: toolbar for Outlook Express Pin
andy14526-Oct-05 23:51
andy14526-Oct-05 23:51 
Questionrandom number that doesn't repeat? Pin
aaadetos26-Oct-05 4:24
aaadetos26-Oct-05 4:24 

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.