I am trying to create a uint8_t
array and try to change the first element of the array, then print it to the terminal as a string.
But, after I assign currBlock
(changed block) to arr[0]
, cout
gives an error. I tried to find the answer in StackOverflow but couldn't find a similar question. Can you help me with it?
Error: bitset::_M_copy_from_ptr
#include <iostream>
#include <sstream>
#include <bitset>
int main()
{
uint8_t arr[3]{0};
uint8_t currBlock{arr[0]};
int flag{1};
currBlock ^= (-flag ^ arr[0]) & (1UL << 3);
cout << "Buffer is : " << bitset<24>(arr).to_string() << endl;
arr[0] = currBlock;
cout << "Buffer is : " << bitset<24>(arr).to_string() << endl;
return 0;
}
I was expecting a print out of the uint8_t
, but instead I get an error.