Conversione dati in Visual C++ - Alessandro Barazzuol

Conversione dati in Visual C++

#include <msclr\marshal_cppstd.h>
#include <string>
#define SIZE 100

/*convertire char array[SIZE] in String ^*/

msclr::interop::marshal_context context;

char array[SIZE];
std::string str="";
str = std::string(array);


/*convertire string in String^*/

String^ STR = gcnew String(str.data());


/*convertire textbox in string*/

String^ msg = this->textBox2->Text;

std::string m = context.marshal_as<std::string>(msg);


/*convertire string in array di caratteri*/

char mm[SIZE];
string s;
strcpy(mm,s.c_str());


/*mettere una stringa in un textbox*/


std::string s="ciao";
this->textBox2->Text = gcnew String(s.data());


/*convertire un intero in string*/

int str_to_int(const std::string & str) {
			std::stringstream ss(str);
			int num;
			ss >> num;
			return num;
		}