W
Wild Wind
Hello,
I have the following methods I've written to convert
from String* to std::string and back:
static void ConvertFromStdString(std::string& inStr,
System:String* outStr)
{
outStr = new String(inStr.c_str());
}
static void ConvertToStdString(System::String* inStr,
std::string& outStr)
{
int len = inStr->Length();
char* charStr = __nogc new char[len + 1];
for (int i = 0; i < len; i++)
{
charStr = (char)inStr->Chars;
}
charStr[len] = '\0';
outStr = charStr;
}
Can anyone tell me if there might be some hidden errors
in these functions (perhaps due to a mixing of managed
and unmanaged variables)?
TIA,
I have the following methods I've written to convert
from String* to std::string and back:
static void ConvertFromStdString(std::string& inStr,
System:String* outStr)
{
outStr = new String(inStr.c_str());
}
static void ConvertToStdString(System::String* inStr,
std::string& outStr)
{
int len = inStr->Length();
char* charStr = __nogc new char[len + 1];
for (int i = 0; i < len; i++)
{
charStr = (char)inStr->Chars;
}
charStr[len] = '\0';
outStr = charStr;
}
Can anyone tell me if there might be some hidden errors
in these functions (perhaps due to a mixing of managed
and unmanaged variables)?
TIA,