Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Working with Byte-Array

Working with Byte-Array

Scheduled Pinned Locked Moved Managed C++/CLI
csharpc++visual-studiodata-structureshelp
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    realmontanakid
    wrote on last edited by
    #1

    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++..

    S 1 Reply Last reply
    0
    • R realmontanakid

      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++..

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Use the array template (or generic, I don't know) class.

      array ^buffer = gcnew array();

      Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      R 1 Reply Last reply
      0
      • S S Senthil Kumar

        Use the array template (or generic, I don't know) class.

        array ^buffer = gcnew array();

        Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        R Offline
        R Offline
        realmontanakid
        wrote on last edited by
        #3

        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

        S 1 Reply Last reply
        0
        • R realmontanakid

          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

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          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>

          R 1 Reply Last reply
          0
          • S S Senthil Kumar

            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>

            R Offline
            R Offline
            realmontanakid
            wrote on last edited by
            #5

            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

            R 1 Reply Last reply
            0
            • R realmontanakid

              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

              R Offline
              R Offline
              realmontanakid
              wrote on last edited by
              #6

              got it.. Thanks a lot

              S 1 Reply Last reply
              0
              • R realmontanakid

                got it.. Thanks a lot

                S Offline
                S Offline
                S Senthil Kumar
                wrote on last edited by
                #7

                Yeah, you need to replace the [] with (). Regards Senthil _____________________________ My Blog | My Articles | WinMacro

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups