How do I translate my code from C# to C++ for a CRC function? : <p>I have the following code in C# to calculate a CRC and it works like I want it to.</p>

<pre><code> public byte crc_8(byte[] byteArray)
    {
        ushort reg_crc = 0;
        for(int i = 0; i&lt;byteArray.Length; i++)
        {
            reg_crc ^= byteArray[i];
            for(int j = 0; j &lt; 8; j++)
            {
                if((reg_crc &amp; 0x01) == 1)
                {
                    reg_crc = (ushort)((reg_crc &gt;&gt; 1) ^ 0xE5);
                }
                else
                {
                    reg_crc = (ushort)(reg_crc &gt;&gt; 1);
                }
            }
        }
        reg_crc = (byte)(reg_crc &amp; 0xFF);
        return (byte)reg_crc;
    } 
</code></pre>

<p>I also need to add this same function to a code project that is in C++, but I am brand new to C++. This is as far as I have gotten, and I am not sure with how to proceed with the code inside of the for loop. Also note that <code>RX_PACKET_SIZE</code> is equivalent to <code>byteArray.Length</code> in that it can be used for the same purpose. I know that is okay.</p>

<pre><code>static uint8_t crc_8(unit8_t array_to_process [])
{
    uint16_t reg_crc = 0;
    for(int i = 0; i &lt; RX_PACKET_SIZE; i++)
    {

    }
}
</code></pre>
