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. C / C++ / MFC
  4. Declare Byte

Declare Byte

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharptutorial
9 Posts 4 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.
  • U Offline
    U Offline
    User 2159113
    wrote on last edited by
    #1

    For C#, the declaration of the byte is as below: public byte[] Header_byte = {0x10,0x00}; public byte[] DataLength_byte; But I don't know how to declare bytes in visual c++

    K T V 3 Replies Last reply
    0
    • U User 2159113

      For C#, the declaration of the byte is as below: public byte[] Header_byte = {0x10,0x00}; public byte[] DataLength_byte; But I don't know how to declare bytes in visual c++

      K Offline
      K Offline
      kakan
      wrote on last edited by
      #2

      If you wan't bytes (8 bits), I suggest you use unsigned char unsigned char Header_byte[] = {0x10,0x00}; unsigned char DataLength_byte[]; or unsigned char *DataLength_byte;

      U 1 Reply Last reply
      0
      • U User 2159113

        For C#, the declaration of the byte is as below: public byte[] Header_byte = {0x10,0x00}; public byte[] DataLength_byte; But I don't know how to declare bytes in visual c++

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        C# bytes are .NET framework type. C++ don't have them. in C/C++, you can use char instead...

        char Header_byte[] = {0x10, 0x00};
        char DataLength_byte[];


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        1 Reply Last reply
        0
        • U User 2159113

          For C#, the declaration of the byte is as below: public byte[] Header_byte = {0x10,0x00}; public byte[] DataLength_byte; But I don't know how to declare bytes in visual c++

          V Offline
          V Offline
          vikas amin
          wrote on last edited by
          #4

          For VC++ declaration of byte is byte buf[]={0x10,0x00}; I have used it in my MFC application and works fine . Locgically it is same as "unsinged char". Vikas Amin Embin Technology Bombay vikas.amin@embin.com

          1 Reply Last reply
          0
          • K kakan

            If you wan't bytes (8 bits), I suggest you use unsigned char unsigned char Header_byte[] = {0x10,0x00}; unsigned char DataLength_byte[]; or unsigned char *DataLength_byte;

            U Offline
            U Offline
            User 2159113
            wrote on last edited by
            #5

            When I use what you suggest,it got error below: error C2146: syntax error : missing ';' before identifier 'Header_byte' error C2377: 'byte' : redefinition;; typedef cannot be overloaded with any other symbol fatal error C1004: unexpected end of file found

            T K 2 Replies Last reply
            0
            • U User 2159113

              When I use what you suggest,it got error below: error C2146: syntax error : missing ';' before identifier 'Header_byte' error C2377: 'byte' : redefinition;; typedef cannot be overloaded with any other symbol fatal error C1004: unexpected end of file found

              T Offline
              T Offline
              toxcct
              wrote on last edited by
              #6

              read what the compilers tells you... it is clear enough. :doh:


              TOXCCT >>> GEII power
              [toxcct][VisualCalc]

              1 Reply Last reply
              0
              • U User 2159113

                When I use what you suggest,it got error below: error C2146: syntax error : missing ';' before identifier 'Header_byte' error C2377: 'byte' : redefinition;; typedef cannot be overloaded with any other symbol fatal error C1004: unexpected end of file found

                K Offline
                K Offline
                kakan
                wrote on last edited by
                #7

                Hello. I just compiled it. This works: unsigned char Header_byte[] = {0x10,0x00}; unsigned char *DataLength_byte2; This one doesn't due to "Unknown datasize": unsigned char DataLength_byte[];

                T 1 Reply Last reply
                0
                • K kakan

                  Hello. I just compiled it. This works: unsigned char Header_byte[] = {0x10,0x00}; unsigned char *DataLength_byte2; This one doesn't due to "Unknown datasize": unsigned char DataLength_byte[];

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #8

                  i give up... he'd better learn C++ first ! :suss:


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  K 1 Reply Last reply
                  0
                  • T toxcct

                    i give up... he'd better learn C++ first ! :suss:


                    TOXCCT >>> GEII power
                    [toxcct][VisualCalc]

                    K Offline
                    K Offline
                    kakan
                    wrote on last edited by
                    #9

                    :)

                    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