#include <stdlib.h>
#include <stdio.h>
#include <vcclr.h>
int main(array<System::String ^> ^args)
{
System::String ^ str = "test";
pin_ptr<const wchar_t> wch = PtrToStringChars(str);
size_t convertedChars = 0;
size_t sizeInBytes = ((str->Length + 1) * 2);
errno_t err = 0;
char* ch = (char *)malloc(sizeInBytes);
err = wcstombs_s(&convertedChars, ch, sizeInBytes,
wch, sizeInBytes);
if (err != 0)
printf_s("wcstombs_s failed!\n");
printf("%s\n", ch);
return 0;
}コメントの投稿