I want to calculate the checksum of my data. After converting the string to binary i now need to sum all of the 8 bit strings (XOR them) such that, if the XOR produces an overflow bit (carry bit) at the end of the sum, that bit should be added to the final sum and the value obtained now is the FINAL value (an 8 bit checksum).
Then i want to take a 1s complement of the 8 bit FINAL value and this new value would be my actual checksum that i can use ahead. I dont know how to take up each of these binary strings and sum them in the first place :(
#include <string>
#include <bitset>
#include <iostream>
using namespace std;
int main()
{
string myString = "Hello World";
for (std::size_t i = 0; i < myString.size(); ++i)
{
cout << bitset<8>(myString.c_str()[i]) << endl;
}
//the indentations might have shaken a bit in copting the code here.
}