char* StringToChar(String^ str)
{
char *ch;
pin_ptr<const wchar_t> wch = PtrToStringChars(str);
size_t convertedChars = 0;
size_t sizeInBytes = ((str->Length + 1) * 2);
ch = (char *)malloc(sizeInBytes);
wcstombs_s(&convertedChars, ch, sizeInBytes, wch, sizeInBytes);
return ch;
}