wchar_t в char
int BUFFER_SIZE = 100;
size_t i;
wchar_t *Inp = L"Hellow to All";
char *Out = (char *)malloc(BUFFER_SIZE);
// преобразование
wcstombs_s(&i, Out, (size_t)BUFFER_SIZE, Inp, (size_t)BUFFER_SIZE);
string в char
#include <string.h>
#include <stdlib.h>
string Inp = "Строка типа string";
const size_t newsize = 100;
char Out[newsize];
strcpy_s(Out, Inp.c_str());
String в char
String ^Inp = gcnew String("Hello, World!");
pin_ptr<const wchar_t> wch = PtrToStringChars(Inp);
size_t Inp_size = wcslen(wch) + 1;
const size_t newsize = 100;
size_t i = 0;
char Out[newsize];
wcstombs_s(&i, Out, Inp_size, wch, _TRUNCATE);
this->textbox->Text = gcnew String(Out);
|