Compilation error in CRC encoding program
<p>I wrote the following code for a program that performs CRC encoding. I modeled it on a C program that we were taught in class. It gives some compilation errors that I can't correct. I have mentioned them after the code.</p>

<pre><code>I wrote the following code for a program that performs CRC encoding. I modeled it on a C program that we were taught in class. It gives some compilation errors that I can't correct. I have mentioned them after the code.

1 #include&lt;iostream&gt;
2 #include&lt;string.h&gt;
3
4 using namespace std;
5
6 class crc
7 {
8   char message[128],polynomial[18],checksum[256];
9   public:
10  void xor()
11  {
12      for(int i=1;i&lt;strlen(polynomial);i++)
13          checksum[i]=((checksum[i]==polynomial[i])?'0':'1');
14  }
15  crc()    //constructor
16  {
17      cout&lt;&lt;"Enter the message:"&lt;&lt;endl;
18      cin&gt;&gt;message;
19      cout&lt;&lt;"Enter the polynomial";
20      cin&gt;polynomial;
21  }
22  void compute()
23  {
24      int e,i;
25      for(e=0;e&lt;strlen(polynomial);e++)
26      checksum[e]=message[e];
27      do
28      {
29          if(checksum[0]=='0')
30          xor();
31          for(i=0;i&lt;(strlen(polynomial)-1);i++)
32              checksum[i]=checksum[i+1];
33          checksum[i]=message[e++];
34      }while(e&lt;=strlen(message)+strlen(checksum)-1);
35  }
36  void gen_proc() //general processing
37  {
38      int mesg_len=strlen(message);
39      for(int i=mesg_len;i&lt;mesg_len+strlen(polynomial)-1;i++)
40          message[i]='0';
41      message[i]='\0'; //necessary?
42      cout&lt;&lt;"After appending zeroes message is:"&lt;&lt;message;
43      compute();
44      cout&lt;&lt;"Checksum is:"&lt;&lt;checksum;
45      for(int i=mesg_len;i&lt;mesg_len+strlen(polynomial);i++)
46      message[i]=checksum[i-mesg_len];
47      cout&lt;&lt;"Final codeword is:"&lt;&lt;message;
48  }
49 };
50 int main()
51 {
52  crc c1;
53  c1.gen_proc();
54  return 0;
55 }
</code></pre>

<p>The compilation errors are:</p>

<pre><code>crc.cpp:10: error: expected unqualified-id before ‘^’ token
crc.cpp: In member function ‘void crc::compute()’:
crc.cpp:30: error: expected primary-expression before ‘^’ token
crc.cpp:30: error: expected primary-expression before ‘)’ token
crc.cpp: In member function ‘void crc::gen_proc()’:
crc.cpp:41: warning: name lookup of ‘i’ changed for ISO ‘for’ scoping
crc.cpp:39: warning:   using obsolete binding at ‘i’
</code></pre>

<p>I have been checking online for these errors and the only thing I have been seeing is errors caused by incorrect array handling. I have double checked my code but I don't seem to be performing any incorrect array access.</p>
