hi there! im trying to do a xor beetwin two cha but i coudl no there is my code:

String^ val2;
String^ val3;
String^ val1;
String^ val;
 char  *chval1;
char  *chval2;
 char  *chval3;
char *chval;
char *chv; 
val1=GZMK1->Text;//GZMK1 is textbox
val2=GZMK2->Text;//GZMK2 is textbox
val3=GZMK3->Text;//GZMK3 is textbox
chval1 = static_cast<char *>(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(val1).ToPointer());
//convert String^ to a char 
	chval2 = static_cast<char *>(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(val2).ToPointer());
	chval3 = static_cast<char *>(System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(val3).ToPointer());
	 
	
for( int i=0;i<sizeof(chval1);i++)
{
	chv[i]=chval1[i]^chval2[i];
}
String ^ str =gcnew String(chv);
GZMK->Text=str;//GZMK is a textbox where i m gonna put my result

leas any body could help me i m gonnaa be a grathful

Recommended Answers

All 5 Replies

line 19: What exactly do you expect sizeof() to return on that line? Answer: sizeof() is returning the size of a pointer, not the length of the string to which it points. In otherwises use of the sizeof operator on that line is meaningless.

ok i see but i stil hav a problem but i don't know what to do cause when i xcute it it's made me an exception whicch i never seen before there is't :


Une exception non gérée du type 'System.NullReferenceException' s'est produite dans interfaceZMK.exe

Informations supplémentaires : La référence d'objet n'est pas définie à une instance d'un objet.

line 21: chv is an uninitialized pointer. You have to allocate memory fo it before that loop.

Dear Ancient Dragon i initianiizd but it still giving me the same exception im blocked

Post newest code and this time use code tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.