Tuesday, January 11, 2005
Converting .NET Managed String Objects to NULL Terminated Char Pointers in C++
This is something that took me a long time to get figured out, and I'm still not sure if I am correctly transfering the data from the managed string object into the NULL terminating char pointer:
1#pragma managed 2char* TranslateRealStringToCharPtr(System::String* strToConvert) 3{ 4 System::String* StringPointer = strToConvert; 5 char* CharPointer = _ 6 (char*)(void*)Marshal::StringToHGlobalAnsi(StringPointer); 7 return CharPointer; 8}
I think that there is a memory leak in the code, but I can't figure out where it is. Any ideas?
posted by Chip Childers @ 8:00 AM
0 comments
![]()
Links to this post



Post a Comment