Working with Byte-Array
-
Hi I try to deepen my knowledge in Visual C++.net.. Up to now I'm always using c#. So I try to port a C# application to Visual C++.net. But it break down on a Byte Array.. In c#... no problem.. Here a little bit from the # App..
byte[] buffer = new byte[1024]; for(int x = 0; x < 6; x++) { buffer[count++] = 0xFF; } for(int i = 0; i < 16; i++) { int tmp = 0; for(int y = 0; y < 6; y++) { buffer[count++] = Byte.Parse(mac.Substring(tmp,2),System.Globalization.NumberStyles.HexNumber); tmp = tmp+2; } } client.Send(buffer,1024);
And now the c++ complement..//System::Byte buffer[1024] //array buffer = gcnew array(1024); //char* buffer[] = new char*[1024]; for(int x = 0; x < 6; x++) { buffer[count++] = 0xFF; } for(int i = 0; i < 16; i++) { int tmp = 0; for(int y = 0; y < 6; y++) { buffer[count++] = Byte::Parse(mac->Substring(tmp,2),System::Globalization::NumberStyles::HexNumber); tmp = tmp+2; } } client->Send(buffer,1024);
I don't know how to work with this array... I searched google for so long.. I know in Visual Studio 2005 there are some language alterations for c++.. -
Hi I try to deepen my knowledge in Visual C++.net.. Up to now I'm always using c#. So I try to port a C# application to Visual C++.net. But it break down on a Byte Array.. In c#... no problem.. Here a little bit from the # App..
byte[] buffer = new byte[1024]; for(int x = 0; x < 6; x++) { buffer[count++] = 0xFF; } for(int i = 0; i < 16; i++) { int tmp = 0; for(int y = 0; y < 6; y++) { buffer[count++] = Byte.Parse(mac.Substring(tmp,2),System.Globalization.NumberStyles.HexNumber); tmp = tmp+2; } } client.Send(buffer,1024);
And now the c++ complement..//System::Byte buffer[1024] //array buffer = gcnew array(1024); //char* buffer[] = new char*[1024]; for(int x = 0; x < 6; x++) { buffer[count++] = 0xFF; } for(int i = 0; i < 16; i++) { int tmp = 0; for(int y = 0; y < 6; y++) { buffer[count++] = Byte::Parse(mac->Substring(tmp,2),System::Globalization::NumberStyles::HexNumber); tmp = tmp+2; } } client->Send(buffer,1024);
I don't know how to work with this array... I searched google for so long.. I know in Visual Studio 2005 there are some language alterations for c++..Use the array template (or generic, I don't know) class.
array ^buffer = gcnew array();
Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Use the array template (or generic, I don't know) class.
array ^buffer = gcnew array();
Regards Senthil _____________________________ My Blog | My Articles | WinMacro
Thank You But how can I bind this class into my project? It throws the following errors... Error 1 error C2955: 'cli::array' : use of class template requires template argument list -- modified at 3:33 Wednesday 28th December, 2005
-
Thank You But how can I bind this class into my project? It throws the following errors... Error 1 error C2955: 'cli::array' : use of class template requires template argument list -- modified at 3:33 Wednesday 28th December, 2005
Oops, I forgot to check the "Do not treat < as tags" checkbox. The post should look like "Use the array template (or generic, I don't know) class." array<byte> ^buffer = gcnew array<byte>[10]; Regards Senthil _____________________________ <font face="Verdana" size=1><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href = "http://www.codeproject.com/script/articles/list\_articles.asp?userid=492196">My Articles</a> | <a href = "http://geocities.com/win\_macro">WinMacro</a></font>
-
Oops, I forgot to check the "Do not treat < as tags" checkbox. The post should look like "Use the array template (or generic, I don't know) class." array<byte> ^buffer = gcnew array<byte>[10]; Regards Senthil _____________________________ <font face="Verdana" size=1><a href="http://blogs.wdevs.com/senthilkumar">My Blog</a> | <a href = "http://www.codeproject.com/script/articles/list\_articles.asp?userid=492196">My Articles</a> | <a href = "http://geocities.com/win\_macro">WinMacro</a></font>
By using this following error...
array ^buffer = gcnew array[1024];
Error 1 error C2065: 'byte' : undeclared identifier Error 2 error C2728: 'cli::array' : a native array cannot contain this managed type Error 3 error C2512: 'cli::array::array' : no appropriate default constructor available c++ is a little bit stranger then #:doh: -- modified at 3:49 Wednesday 28th December, 2005 -
By using this following error...
array ^buffer = gcnew array[1024];
Error 1 error C2065: 'byte' : undeclared identifier Error 2 error C2728: 'cli::array' : a native array cannot contain this managed type Error 3 error C2512: 'cli::array::array' : no appropriate default constructor available c++ is a little bit stranger then #:doh: -- modified at 3:49 Wednesday 28th December, 2005got it.. Thanks a lot
-
got it.. Thanks a lot
Yeah, you need to replace the [] with (). Regards Senthil _____________________________ My Blog | My Articles | WinMacro