title: Passing a byte array to a function
body: <p>I apologize for the question(completely newbie), the following function is available in the USPS website for generating barcodes. the documentation shows this:
  USPS_MSB_Math_CRC11GenerateFrameCheckSequence(016907B2A24ABC16A2E5C004B1(HEX)) = 751(HEX)</p>
  
  <p>I've tried many things(passing the hexadecimals, puting 0x in front, passing binary) but I can get the correct result, how am I suppossed to pass the hexadecimal values to the function? any ideas/suggestions/corrections please... thank you very very much!</p>
  
  <pre><code>/*Inputs: ByteArrayPtr is the address of a 13 byte array holding 102 bits which
   are right justified - ie: the leftmost 2 bits of the first byte do not
   hold data and must be set to zero.
  
   Outputs: Outputs:return unsigned short - 11 bit Frame Check Sequence (right justified)
  */
  
  extern unsigned short
  USPS_MSB_Math_CRC11GenerateFrameCheckSequence( unsigned char *ByteArrayPtr )
  {
  unsigned short  GeneratorPolynomial = 0x0F35;
  unsigned short  FrameCheckSequence  = 0x07FF;
  unsigned short  Data;
  int             ByteIndex,Bit;
  
  /* Do most significant byte skipping the 2 most significant bits */
  Data = *ByteArrayPtr &lt;&lt; 5;
  ByteArrayPtr++;
  
  for ( Bit = 2; Bit &lt; 8; Bit++ ) {
      if ( (FrameCheckSequence ^ Data) &amp; 0x400 )
          FrameCheckSequence = (FrameCheckSequence &lt;&lt; 1) ^ GeneratorPolynomial;
      else
          FrameCheckSequence = (FrameCheckSequence &lt;&lt; 1);
      FrameCheckSequence &amp;= 0x7FF;
      Data &lt;&lt;= 1;
  }
  
  /* Do rest of the bytes */
  for ( ByteIndex = 1; ByteIndex &lt; 13; ByteIndex++ ) {
      Data = *ByteArrayPtr &lt;&lt; 3;
      ByteArrayPtr++;
      for ( Bit = 0; Bit &lt; 8; Bit++ ) {
          if ( (FrameCheckSequence ^ Data) &amp; 0x0400 )
              FrameCheckSequence = (FrameCheckSequence &lt;&lt; 1) ^ GeneratorPolynomial;
          else
              FrameCheckSequence = (FrameCheckSequence &lt;&lt; 1);
  
          FrameCheckSequence &amp;= 0x7FF;
          Data &lt;&lt;= 1;
      }
  }
  
  return FrameCheckSequence;
  }
  </code></pre>