Здравствуйте, Wolf-alone, Вы писали:
WA>>>У этого самого "TextBox'a" нет "c_str"! Я так уже пробовал... Он в каком-то странном формате строку "даёт", и сделать с ней ничего не могу!
ZAV>>Дак всё таки какой тип textBox1->Text? Если std::basic_string то есть и std::basic_string::c_str.
WA>Если сделать так: textBox1->Text:: , то будет всего два метода: ::set и ::get.
WA>В общем если сделать так: char str[100]=textBox1->Text; то будет вот что:
WA>error C2440: '=' : cannot convert from 'System::String ^' to 'char [100]'
Так у тебя managed C++, что ли ? Что ж ты в первом посте про basic_string писал? У тебя там System::String. Используй
PtrToStringChars. Читай MSDN:
// convert_string_to_wchar.cpp
// compile with: /clr
#include < stdio.h >
#include < stdlib.h >
#include < vcclr.h >
using namespace System;
int main() {
String ^str = "Hello";
// Pin memory so GC can't move it while native function is called
pin_ptr<const wchar_t> wch = PtrToStringChars(str);
printf_s("%S\n", wch);
// Conversion to char* :
// Can just convert wchar_t* to char* using one of the
// conversion functions such as:
// WideCharToMultiByte()
// wcstombs_s()
// ... etc
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("%s\n", ch);
}