i needed to write a simple program to demonstrate the CRC mechanism in Networks. i needed a string of bools to be XORed with the polynomial. Well, i used <bitset> but that did not help much. So i just used a bool vector.
This is how i proceeded. Here, when i give 'a' in the input stream, the string terminates.(Can use return also for this).
However, for this input:
1010101a
1a
this is my output:
11
im not sure how im getting the extra "1" there.
Can anyone please help?
int main()
{
vector<bool> sourceData;
vector<bool> errorData;
vector<bool> copyData;
int c;
while ( (c = getchar()) != 'a' ) {
sourceData.push_back(c);
}
while ( (c = getchar()) != 'a' ) {
errorData.push_back(c);
}
for (int i = 0; i < errorData.size(); i++)
cout << errorData[i];
return 0;
}
PS: ANy other method or approach for the CRC problem?