karateboy02
Programmer
I am trying to convert from a System::String to a char array. I have found a code snippet that works in Visual Studio 2005 but when I try to run the same exact code in Visual Studio 2003 I get several errors. The code looks like:
System::String *orig = this->textBox1->Text;
pin_ptr<const wchar_t> wch = PtrToStringChars(orig);
size_t origsize = wcslen(wch) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
char nstring[newsize];
wcstombs_s(&convertedChars, nstring, origsize, wch, _TRUNCATE);
Where nstring should be where the string ends up. The errors that I get are:
(143): error C2065: 'pin_ptr' : undeclared identifier
(143): error C2059: syntax error : 'const'
(146): error C2065: 'wch' : undeclared identifier
(150): error C2065: '_TRUNCATE' : undeclared identifier
(150): error C3861: 'wcstombs_s': identifier not found, even with argument-dependent lookup
(150): error C3861: 'wch': identifier not found, even with argument-dependent lookup
Any help would be much appreciated.
System::String *orig = this->textBox1->Text;
pin_ptr<const wchar_t> wch = PtrToStringChars(orig);
size_t origsize = wcslen(wch) + 1;
const size_t newsize = 100;
size_t convertedChars = 0;
char nstring[newsize];
wcstombs_s(&convertedChars, nstring, origsize, wch, _TRUNCATE);
Where nstring should be where the string ends up. The errors that I get are:
(143): error C2065: 'pin_ptr' : undeclared identifier
(143): error C2059: syntax error : 'const'
(146): error C2065: 'wch' : undeclared identifier
(150): error C2065: '_TRUNCATE' : undeclared identifier
(150): error C3861: 'wcstombs_s': identifier not found, even with argument-dependent lookup
(150): error C3861: 'wch': identifier not found, even with argument-dependent lookup
Any help would be much appreciated.