CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    join 2 unsigned char

    i needed to join 2 unsigned char as in

    Code:
    unsigned  short temp =  0x3e + 0x20 ;
    // I do not want to add them 
    // resulting short should look like   0x3e20

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    Re: join 2 unsigned char

    One way is to use a left shift and then a bitwise or (or just add), but note that the result is unlikely to fit into an unsigned char (without changing its value).
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Aug 2008
    Posts
    902

    Re: join 2 unsigned char

    Code:
    unsigned  short temp =  (0x3e << 8) + 0x20;

  4. #4
    Join Date
    Mar 2010
    Location
    Melbourne Australia
    Posts
    454

    Re: join 2 unsigned char

    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured