Click here to Skip to main content
15,885,979 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: gpedit.msc from VC++ Pin
Michael Schubert14-Apr-09 6:47
Michael Schubert14-Apr-09 6:47 
QuestionC# / C++ Interop, Odd behaviour from marshalled strings Pin
Mikey_H14-Apr-09 3:50
Mikey_H14-Apr-09 3:50 
AnswerRe: C# / C++ Interop, Odd behaviour from marshalled strings Pin
Chris Losinger14-Apr-09 4:35
professionalChris Losinger14-Apr-09 4:35 
GeneralRe: C# / C++ Interop, Odd behaviour from marshalled strings [modified] Pin
Mikey_H14-Apr-09 5:16
Mikey_H14-Apr-09 5:16 
GeneralRe: C# / C++ Interop, Odd behaviour from marshalled strings [modified] Pin
Chris Losinger14-Apr-09 5:29
professionalChris Losinger14-Apr-09 5:29 
GeneralRe: C# / C++ Interop, Odd behaviour from marshalled strings Pin
Iain Clarke, Warrior Programmer14-Apr-09 5:33
Iain Clarke, Warrior Programmer14-Apr-09 5:33 
GeneralRe: C# / C++ Interop, Odd behaviour from marshalled strings Pin
Chris Losinger14-Apr-09 5:40
professionalChris Losinger14-Apr-09 5:40 
GeneralRe: C# / C++ Interop, Odd behaviour from marshalled strings Pin
Iain Clarke, Warrior Programmer14-Apr-09 5:30
Iain Clarke, Warrior Programmer14-Apr-09 5:30 
The second comparison is the correct one.

Two facts you need to know.

1/ m_meshName is a pointer to character. Underneath, it's an integer holding an address in RAM.
2/ The compiler has seen two constant strings in your code, but only bothers to store one copy of the string "Pyramid3" in it's data segment.

So, the strcmp works as intended, and makes m_meshName point to the constant string in your code.

The 3rd comparison works by luck, as m_meshName is still pointing to that string. This is because your compiler is being efficient, it is not because your code is correct.

You are lucky.

If this doesn't sink in (it's hard until you have a lightbulb moment), I can recommend reading The Complete Guide to C++ Strings, Part I - Win32 Character Encodings[^]

Iain.

In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job! http://cv.imcsoft.co.uk/[^]

GeneralRe: C# / C++ Interop, Odd behaviour from marshalled strings Pin
Mikey_H14-Apr-09 6:34
Mikey_H14-Apr-09 6:34 
QuestionHaving a generic function GetProcAddress for both unicode and ascii builds - fails in release mode Pin
Priya_Sundar14-Apr-09 3:43
Priya_Sundar14-Apr-09 3:43 
AnswerRe: Having a generic function GetProcAddress for both unicode and ascii builds - fails in release mode Pin
Iain Clarke, Warrior Programmer14-Apr-09 4:07
Iain Clarke, Warrior Programmer14-Apr-09 4:07 
AnswerRe: Having a generic function GetProcAddress for both unicode and ascii builds - fails in release mode Pin
CPallini14-Apr-09 5:47
mveCPallini14-Apr-09 5:47 
GeneralRe: Having a generic function GetProcAddress for both unicode and ascii builds - fails in release mode Pin
Priya_Sundar14-Apr-09 17:12
Priya_Sundar14-Apr-09 17:12 
Questionhow to create new thread Pin
hemlat14-Apr-09 3:39
hemlat14-Apr-09 3:39 
AnswerRe: how to create new thread Pin
Divyang Mithaiwala14-Apr-09 3:53
Divyang Mithaiwala14-Apr-09 3:53 
GeneralRe: how to create new thread Pin
hemlat14-Apr-09 4:01
hemlat14-Apr-09 4:01 
GeneralRe: how to create new thread Pin
Divyang Mithaiwala14-Apr-09 4:04
Divyang Mithaiwala14-Apr-09 4:04 
GeneralRe: how to create new thread Pin
Rajesh R Subramanian14-Apr-09 4:11
professionalRajesh R Subramanian14-Apr-09 4:11 
GeneralRe: how to create new thread Pin
ThatsAlok14-Apr-09 20:20
ThatsAlok14-Apr-09 20:20 
GeneralRe: how to create new thread Pin
Rajesh R Subramanian14-Apr-09 4:17
professionalRajesh R Subramanian14-Apr-09 4:17 
AnswerRe: how to create new thread Pin
Divyang Mithaiwala14-Apr-09 4:02
Divyang Mithaiwala14-Apr-09 4:02 
AnswerRe: how to create new thread Pin
Rajesh R Subramanian14-Apr-09 4:19
professionalRajesh R Subramanian14-Apr-09 4:19 
QuestionRe: how to create new thread Pin
David Crow14-Apr-09 4:37
David Crow14-Apr-09 4:37 
AnswerRe: how to create new thread Pin
hemlat14-Apr-09 20:34
hemlat14-Apr-09 20:34 
GeneralRe: how to create new thread Pin
Rajesh R Subramanian14-Apr-09 20:39
professionalRajesh R Subramanian14-Apr-09 20:39 

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.